82 lines
2.4 KiB
C#
82 lines
2.4 KiB
C#
using System;
|
|
|
|
public class Example
|
|
{
|
|
public static void FocusChangedCb(object sender, EventArgs e)
|
|
{
|
|
Console.WriteLine($"Focus for object {((Efl.Text)sender).GetText()} changed to {((Efl.Ui.Widget)sender).GetFocus()}");
|
|
}
|
|
|
|
#if WIN32
|
|
[STAThreadAttribute()]
|
|
#endif
|
|
public static void Main()
|
|
{
|
|
// Initialize EFL and all UI components
|
|
Efl.All.Init(Efl.Components.Ui);
|
|
|
|
// Create a window and initialize it
|
|
var win = new Efl.Ui.Win(null);
|
|
win.SetWinType(Efl.Ui.WinType.Basic);
|
|
win.SetText("Focus example");
|
|
win.SetAutohide(true);
|
|
win.HideEvt += (object sender, EventArgs e) => {
|
|
// Exit the EFL main loop
|
|
Efl.Ui.Config.Exit();
|
|
};
|
|
|
|
|
|
// Create the main box container
|
|
var vbox = new Efl.Ui.Box(win);
|
|
vbox.SetHintMin(new Eina.Size2D(360, 240));
|
|
win.SetContent(vbox);
|
|
|
|
// Create some check boxes
|
|
Efl.Ui.Check first_checkbox = null;
|
|
for (int i = 0; i< 5; i++) {
|
|
var checkbox = new Efl.Ui.Check(vbox);
|
|
checkbox.SetText("Check " + i);
|
|
checkbox.SetHintAlign(0.5, 0.5);
|
|
checkbox.FocusChangedEvt += FocusChangedCb;
|
|
vbox.DoPack(checkbox);
|
|
if (i == 0) first_checkbox = checkbox;
|
|
};
|
|
|
|
// Create an horizontal box to contain the two buttons
|
|
var hbox = new Efl.Ui.Box(vbox);
|
|
hbox.SetDirection(Efl.Ui.Dir.Horizontal);
|
|
vbox.DoPack(hbox);
|
|
|
|
// Create a "Focus Mover" button
|
|
var button = new Efl.Ui.Button(hbox);
|
|
button.SetText("Focus mover");
|
|
button.FocusChangedEvt += FocusChangedCb;
|
|
button.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(button);
|
|
|
|
// Create a Quit button
|
|
button = new Efl.Ui.Button(hbox);
|
|
button.SetText("Quit");
|
|
button.FocusChangedEvt += FocusChangedCb;
|
|
button.ClickedEvt += (object sender, EventArgs e) => {
|
|
Console.WriteLine("Clicked Quit");
|
|
Efl.Ui.Config.Exit();
|
|
};
|
|
hbox.DoPack(button);
|
|
|
|
// Show the focus highlight
|
|
win.SetFocusHighlightEnabled(true);
|
|
|
|
// Start the EFL main loop
|
|
Efl.Ui.Config.Run();
|
|
|
|
// Shutdown EFL
|
|
Efl.All.Shutdown();
|
|
}
|
|
}
|
|
|