Improved CLRHOME Key handling

When textinput is focused, the key is handled by the browser (Moving
to start of text).
Otherwise the Content is scrolled to the top.
This commit is contained in:
Ole Loots 2013-04-13 15:34:08 +02:00
parent 437304b037
commit 4e6bea9204
2 changed files with 14 additions and 6 deletions

View File

@ -117,7 +117,7 @@ struct s_menu_item_evnt menu_evnt_tbl[] =
{T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
{T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
{T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
{T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
{T_NAV, MAINMENU_M_HOME, menu_home, {0,0,0}, NULL},
{T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
{T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
{T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
@ -169,7 +169,7 @@ static void __CDECL menu_about(short item, short title, void *data)
}
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
}
}
}
static void __CDECL menu_new_win(short item, short title, void *data)
@ -179,7 +179,7 @@ static void __CDECL menu_new_win(short item, short title, void *data)
const char *addr;
LOG(("%s", __FUNCTION__));
if (nsoption_charp(homepage_url) != NULL) {
addr = nsoption_charp(homepage_url);
} else {
@ -250,7 +250,7 @@ static void __CDECL menu_open_file(short item, short title, void *data)
NULL,
NULL);
nsurl_unref(url);
}
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);

View File

@ -173,11 +173,14 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
// handle key
uint16_t nkc = gem_to_norm( (short)ev_out->emo_kmeta,
(short)ev_out->emo_kreturn);
LOG(("rootwin MU_KEYBD input, nkc: %x\n", nkc));
retval = on_window_key_input(data->rootwin, nkc);
// printf("on_window_key_input: %d\n", retval);
}
if ((ev_out->emo_events & MU_BUTTON) != 0) {
LOG(("rootwin MU_BUTTON input, x: %d, y: %d\n", ev_out->emo_mouse.p_x,
ev_out->emo_mouse.p_x));
window_get_grect(data->rootwin, BROWSER_AREA_CONTENT,
&area);
if (POINT_WITHIN(ev_out->emo_mouse.p_x, ev_out->emo_mouse.p_y,
@ -470,10 +473,10 @@ void window_scroll_by(ROOTWIN *root, int sx, int sy)
GRECT content_area;
struct gemtk_wm_scroll_info_s *slid = gemtk_wm_get_scroll_info(root->win);
if(sx < 0) {
if (sx < 0) {
sx = 0;
}
if(sy<0) {
if (sy < 0) {
sy = 0;
}
int xunits = sx / slid->x_unit_px;
@ -1343,6 +1346,11 @@ static bool on_content_keypress(struct browser_window *bw, unsigned short nkc)
r = true;
break;
case KEY_TEXT_START:
window_scroll_by(bw->window->root, 0, 0);
r = true;
break;
default:
break;
}