Navigation Menu

Skip to content

Commit

Permalink
[Xwt] Add simple method to register autocompletion data on entry widg…
Browse files Browse the repository at this point in the history
…ets.

Currently only implemented for the Gtk+ backend.
  • Loading branch information
garuma committed May 14, 2015
1 parent 48076d1 commit cf3fe0f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Xwt.Gtk/Xwt.GtkBackend/TextEntryBackend.cs
Expand Up @@ -174,6 +174,23 @@ public override void Initialize ()
public bool MultiLine {
get; set;
}

public void SetCompletions (string[] completions)
{
if (completions == null || completions.Length = 0) {

This comment has been minimized.

Copy link
@alanmcgovern

alanmcgovern May 17, 2015

Member

this has completions.Length = 0, it should be completions.Length == 0

Widget.Completion = null;
return;
}

var model = new Gtk.ListStore (typeof(string));
foreach (var c in completions)
model.SetValue (model.Append (), 0, c);
Widget.Completion = new Gtk.EntryCompletion () {
Model = model,
PopupCompletion = true,
TextColumn = 0
};
}

public override void EnableEvent (object eventId)
{
Expand Down
4 changes: 4 additions & 0 deletions Xwt.WPF/Xwt.WPFBackend/TextEntryBackend.cs
Expand Up @@ -155,6 +155,10 @@ public bool ShowFrame
}
}

public void SetCompletions (string[] completions)
{
}

public override void EnableEvent (object eventId)
{
base.EnableEvent (eventId);
Expand Down
4 changes: 4 additions & 0 deletions Xwt.XamMac/Xwt.Mac/TextEntryBackend.cs
Expand Up @@ -238,6 +238,10 @@ void HandleSelectionChanged ()
}
}

public void SetCompletions (string[] completions)
{
}

#endregion


Expand Down
1 change: 1 addition & 0 deletions Xwt/Xwt.Backends/ITextEntryBackend.cs
Expand Up @@ -39,6 +39,7 @@ public interface ITextEntryBackend: IWidgetBackend
int SelectionStart { get; set; }
int SelectionLength { get; set; }
string SelectedText { get; set; }
void SetCompletions (string[] completions);
}

public interface ITextEntryEventSink: IWidgetEventSink
Expand Down
5 changes: 5 additions & 0 deletions Xwt/Xwt/TextEntry.cs
Expand Up @@ -136,6 +136,11 @@ protected override BackendHost CreateBackendHost ()
set { Backend.MultiLine = value; }
}

public void SetCompletions (string[] completions)
{
Backend.SetCompletions (completions);
}

protected virtual void OnChanged (EventArgs e)
{
if (changed != null)
Expand Down

2 comments on commit cf3fe0f

@residuum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a dupkicate of the functionality of Xwt.ComboBox?

@garuma
Copy link
Contributor Author

@garuma garuma commented on cf3fe0f May 21, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's used to provide completion functionality, not a actionable dropdown.

Please sign in to comment.