mirror of
https://github.com/brl/mutter.git
synced 2024-12-28 22:02:14 +00:00
daea8af85e
* clutter/clutter-entry.h: * clutter/clutter-entry.c: (clutter_entry_handle_key_event_internal), (clutter_entry_key_press), (clutter_entry_class_init), (clutter_entry_handle_key_event): Handle a default class handler for the key-press-event, so that giving key focus to an entry will automatically make it work. This deprecates the clutter_entry_handle_key_event() function. (#824) * tests/test-entry.c (main): Remove the handle_key_event() machinery, and just give focus to the entry.
47 lines
1.4 KiB
C
47 lines
1.4 KiB
C
#include <clutter/clutter.h>
|
|
|
|
static void
|
|
on_entry_activated (ClutterEntry *entry, gpointer null)
|
|
{
|
|
g_print ("Activated: %s\n", clutter_entry_get_text (entry));
|
|
}
|
|
|
|
int
|
|
main (int argc, char *argv[])
|
|
{
|
|
ClutterActor *entry;
|
|
ClutterActor *stage;
|
|
ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff };
|
|
ClutterColor entry_color = { 0x33, 0xdd, 0xff, 0xff };
|
|
|
|
clutter_init (&argc, &argv);
|
|
|
|
stage = clutter_stage_get_default ();
|
|
|
|
clutter_actor_set_size (stage, 800, 600);
|
|
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
|
|
clutter_stage_set_title (CLUTTER_STAGE (stage), "ClutterEntry Test");
|
|
|
|
entry = clutter_entry_new_with_text ("Sans 14",
|
|
"Type something, be sure to use the "
|
|
"left/right arrow keys to move the "
|
|
"cursor position.");
|
|
clutter_entry_set_color (CLUTTER_ENTRY (entry), &entry_color);
|
|
clutter_actor_set_size (entry, 600, 50);
|
|
clutter_actor_set_position (entry, 100, 100);
|
|
/*clutter_entry_set_visibility (CLUTTER_ENTRY (entry), FALSE);*/
|
|
/*clutter_entry_set_max_length (CLUTTER_ENTRY (entry), 50);*/
|
|
|
|
clutter_group_add (CLUTTER_GROUP (stage), entry);
|
|
clutter_stage_set_key_focus (CLUTTER_STAGE (stage), entry);
|
|
|
|
clutter_actor_show_all (stage);
|
|
|
|
g_signal_connect (entry, "activate",
|
|
G_CALLBACK (on_entry_activated), NULL);
|
|
|
|
clutter_main();
|
|
|
|
return 0;
|
|
}
|