2018-02-09 13:06:13 -08:00
|
|
|
using System;
|
|
|
|
|
|
|
|
public class Example
|
|
|
|
{
|
|
|
|
public static void FocusChangedCb(object sender, EventArgs e)
|
|
|
|
{
|
2018-07-04 08:48:09 -07:00
|
|
|
Console.WriteLine($"Focus for object {((efl.IText)sender).GetText()} changed to {((efl.ui.IWidget)sender).GetFocus()}");
|
2018-02-09 13:06:13 -08:00
|
|
|
}
|
|
|
|
|
2018-09-18 08:48:36 -07:00
|
|
|
#if WIN32
|
|
|
|
[STAThreadAttribute()]
|
|
|
|
#endif
|
2018-02-09 13:06:13 -08:00
|
|
|
public static void Main()
|
|
|
|
{
|
2018-09-18 08:48:36 -07:00
|
|
|
// Initialize EFL and all UI components
|
2018-02-09 13:06:13 -08:00
|
|
|
efl.All.Init(efl.Components.Ui);
|
|
|
|
|
2018-09-18 08:48:36 -07:00
|
|
|
// Create a window and initialize it
|
|
|
|
var win = new efl.ui.Win(null, (efl.ui.IWin ewin) => {
|
2018-07-04 08:48:09 -07:00
|
|
|
ewin.SetWinType(efl.ui.Win_Type.Basic);
|
2018-09-18 08:48:36 -07:00
|
|
|
ewin.SetText("Focus example");
|
2018-02-09 13:06:13 -08:00
|
|
|
ewin.SetAutohide(true);
|
2018-09-18 08:48:36 -07:00
|
|
|
ewin.HideEvt += (object sender, EventArgs e) => {
|
|
|
|
// Exit the EFL main loop
|
|
|
|
efl.ui.Config.Exit();
|
|
|
|
};
|
2018-02-09 13:06:13 -08:00
|
|
|
});
|
|
|
|
|
2018-09-18 08:48:36 -07:00
|
|
|
// Create the main box container
|
|
|
|
var vbox = new efl.ui.Box(win, (efl.ui.IBox ebox) => {
|
|
|
|
ebox.SetHintMin(new eina.Size2D(360, 240));
|
|
|
|
win.SetContent(ebox);
|
|
|
|
});
|
2018-02-09 13:06:13 -08:00
|
|
|
|
2018-09-18 08:48:36 -07:00
|
|
|
// Create some check boxes
|
|
|
|
efl.ui.ICheck first_checkbox = null;
|
|
|
|
for (int i = 0; i< 5; i++) {
|
|
|
|
var checkbox = new efl.ui.Check(vbox, (efl.ui.ICheck echeck) => {
|
|
|
|
echeck.SetText("Check " + i);
|
|
|
|
echeck.SetHintAlign(0.5, 0.5);
|
|
|
|
echeck.FocusChangedEvt += FocusChangedCb;
|
|
|
|
vbox.DoPack(echeck);
|
|
|
|
});
|
|
|
|
if (i == 0) first_checkbox = checkbox;
|
|
|
|
};
|
2018-02-09 13:06:13 -08:00
|
|
|
|
2018-09-18 08:48:36 -07:00
|
|
|
// Create an horizontal box to contain the two buttons
|
|
|
|
var hbox = new efl.ui.Box(vbox, (efl.ui.IBox ebox) => {
|
|
|
|
ebox.SetDirection(efl.ui.Dir.Horizontal);
|
|
|
|
vbox.DoPack(ebox);
|
|
|
|
});
|
2018-02-09 13:06:13 -08:00
|
|
|
|
2018-09-18 08:48:36 -07:00
|
|
|
// Create a "Focus Mover" button
|
|
|
|
new efl.ui.Button(hbox, (efl.ui.IButton ebutton) => {
|
|
|
|
ebutton.SetText("Focus mover");
|
|
|
|
ebutton.FocusChangedEvt += FocusChangedCb;
|
|
|
|
ebutton.ClickedEvt += (object sender, EventArgs e) => {
|
|
|
|
Console.WriteLine("Clicked Focus Mover");
|
|
|
|
// Manually transfer focus to the first check box
|
|
|
|
efl.ui.focus.Util.Focus(first_checkbox);
|
|
|
|
};
|
|
|
|
hbox.DoPack(ebutton);
|
|
|
|
});
|
2018-02-09 13:06:13 -08:00
|
|
|
|
2018-09-18 08:48:36 -07:00
|
|
|
// Create a Quit button
|
|
|
|
new efl.ui.Button(hbox, (efl.ui.IButton ebutton) => {
|
|
|
|
ebutton.SetText("Quit");
|
|
|
|
ebutton.FocusChangedEvt += FocusChangedCb;
|
|
|
|
ebutton.ClickedEvt += (object sender, EventArgs e) => {
|
|
|
|
Console.WriteLine("Clicked Quit");
|
|
|
|
efl.ui.Config.Exit();
|
|
|
|
};
|
|
|
|
hbox.DoPack(ebutton);
|
|
|
|
// Set focus on this widget and show the focus highlight
|
|
|
|
ebutton.SetFocusHighlightEnabled(true);
|
|
|
|
});
|
2018-02-09 13:06:13 -08:00
|
|
|
|
2018-09-18 08:48:36 -07:00
|
|
|
// Start the EFL main loop
|
2018-02-09 13:06:13 -08:00
|
|
|
efl.ui.Config.Run();
|
|
|
|
|
2018-09-18 08:48:36 -07:00
|
|
|
// Shutdown EFL
|
2018-02-09 13:06:13 -08:00
|
|
|
efl.All.Shutdown();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|