Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
Fix the max lengh of the PopupEntry (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
rookiejava authored Oct 5, 2020
1 parent 47bb6bc commit bc4fbae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/Tizen.Wearable.CircularUI.Forms.Renderer/PopupEntryRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Xamarin.Forms.Platform.Tizen.Native;
using EColor = ElmSharp.Color;
using ELayout = ElmSharp.Layout;
using EEntry = ElmSharp.Entry;
using XForms = Xamarin.Forms.Forms;
using XEntry = Xamarin.Forms.Entry;

Expand Down Expand Up @@ -128,6 +129,7 @@ void CreatePopup()
_editor.Scrollable = true;
_editor.SetInputPanelEnabled(false);
_editor.AllowFocus(true);
_editor.PrependMarkUpFilter(PopupEntryMaxLengthFilter);
_editor.Show();

_editor.SetInputPanelReturnKeyType(Element.ReturnType.ToInputPanelReturnKeyType());
Expand Down Expand Up @@ -156,6 +158,14 @@ void PopupEntryActivated(object sender, EventArgs e)
((IEntryController)Element).SendCompleted();
}

string PopupEntryMaxLengthFilter(EEntry entry, string s)
{
if (entry.Text.Length < Element.MaxLength)
return s;

return null;
}

void HidePopup()
{
if (Control is IEntry ie)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
BackgroundColor="Gray"
HorizontalOptions="FillAndExpand"
TextColor="Blue"
Placeholder="Foobar"
Placeholder="Max Lenth=4"
PlaceholderColor="Blue"
VerticalOptions="CenterAndExpand"
ReturnType="Search"
MaxLength="4"
x:Name="PopupEntry1"/>
<w:PopupEntry
AutomationId="popupEntry2"
Expand Down

0 comments on commit bc4fbae

Please sign in to comment.