Murga-Projects Forums

Full Version: Making scroll ignore pageup/pagedown/home/end?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've been trying to work out a way to navigate Fl_Browser using keyboard only, and running into a problem with the scroll automatically grabbing certain keystrokes and ignoring actions specifically associated with those events. In Fl_Hold_Browser using Up and Down to move the section up and down one line at a time works as expected without modification. However, PageUp, PageDown, Home, and End will only move the scroll...the browser selection doesn't change, so you still have to click to select.

I tried setting up a global menu bar to detect these events, and specifically move the selection accordingly. It works only if the browser does not have focus. I thought a global menu was supposed to work no matter what widget has focus, but there seems to be some hard-coded events associated with some widgets.

Any ideas how to accomplish this, other than by using non-standard keys to do the navigation? It works fine if I use keys not generally associated with navigation, but PageUp/PageDown are so common it seems really weird to use anything else.

function nav_browser()
if Fl:event_key() == fltk.FL_Home then
elseif Fl:event_key() == fltk.FL_End then
elseif Fl:event_key() == fltk.FL_Page_Up then
elseif Fl:event_key() == fltk.FL_Page_Down then
-- can't figure this one yet
-- why can you use topline() without an argument, but not bottomline()?

win = fltk:Fl_Window(400,500,"browser nav test")
browser = fltk:Fl_Hold_Browser(0,0,400,500)
browser_ctrl = fltk:Fl_Menu_Bar(400,500,10,10)
browser_ctrl:add("home", fltk.FL_Home, nav_browser)
browser_ctrl:add("end", fltk.FL_End, nav_browser)
browser_ctrl:add("up", fltk.FL_Page_Up, nav_browser)
browser_ctrl:add("down", fltk.FL_Page_Down, nav_browser)

for line = 1,100 do browser:add("Line "..line) end


Reference URL's