From 82dd81b859cfefe2a5d3537f0145b35af2f10548 Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Wed, 12 Jul 2006 15:07:37 +0000 Subject: Pass on RETURN and ESCAPE events to WIMP icon. svn path=/trunk/netsurf/; revision=2734 --- riscos/textarea.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'riscos') diff --git a/riscos/textarea.c b/riscos/textarea.c index 57c61076f..2a8d84efa 100644 --- a/riscos/textarea.c +++ b/riscos/textarea.c @@ -57,6 +57,9 @@ static struct text_area { // unsigned int selection_start; /**< Character index of sel start */ // unsigned int selection_end; /**< Character index of sel end */ + wimp_w parent; /**< Parent window handle */ + wimp_i icon; /**< Parent icon handle */ + char *font_family; /**< Font family of text */ unsigned int font_size; /**< Font size (16ths/pt) */ int line_height; /**< Total height of a line, given font size */ @@ -127,7 +130,9 @@ uintptr_t textarea_create(wimp_w parent, wimp_i icon, unsigned int flags, LOG(("malloc failed")); return 0; } - + + ret->parent = parent; + ret->icon = icon; ret->magic = MAGIC; ret->flags = flags; ret->text = malloc(64); @@ -934,7 +939,7 @@ bool textarea_key_press(wimp_key *key) static int alphabet = 0; static wchar_t wc = 0; /* buffer for UTF8 alphabet */ static int shift = 0; - + wimp_key keypress; struct text_area *ta; wchar_t c = (wchar_t)key->c; int t_alphabet; @@ -1076,6 +1081,28 @@ bool textarea_key_press(wimp_key *key) } } + /** \todo handle command keys */ + switch (c) { + /** pass on RETURN and ESCAPE to the parent icon */ + case wimp_KEY_RETURN: + if (ta->flags & TEXTAREA_MULTILINE) + break; + /* fall through */ + case wimp_KEY_ESCAPE: + keypress = *key; + keypress.w = ta->parent; + keypress.i = ta->icon; + keypress.index = 0; /* undefined if not in an icon */ + error = xwimp_send_message_to_window(wimp_KEY_PRESSED, + (wimp_message*)&keypress, ta->parent, + ta->icon, 0); + if (error) { + LOG(("xwimp_send_message: 0x%x:%s", + error->errnum, error->errmess)); + } + return true; + } + utf8_len = utf8_from_ucs4(c, utf8); utf8[utf8_len] = '\0'; @@ -1094,9 +1121,6 @@ bool textarea_key_press(wimp_key *key) textarea_redraw_internal(&update, true); } } - - /** \todo handle command keys */ - return true; } -- cgit v1.2.3