Stein-Erik
2010-Apr-26 06:26 UTC
[fxruby-users] FXRuby: Tab key navigation not working properly in my test program
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
Hello!<br>
<br>
I am a great fan of applications that give the user the choice: The
user should be able to do everything in the GUI without using the mouse
if she so wishes. Ie everything should be doable with the keyboard, if
the user for some reason doesn''t want to use the mouse.<br>
<br>
I have just started using FXRuby, bought the ''Lean and Mean''
book, and
have looked through quite a lot of infomation in the archives and
through Google searches.<br>
<br>
I found this Fox page that describes focus:<br>
<a class="moz-txt-link-freetext"
href="http://www.fox-toolkit.org/focus.html">http://www.fox-toolkit.org/focus.html</a><br>
Since the URL doesn''t have any version number, I assume this is the
official Fox documentation on how focus should work.<br>
<br>
I put together a test program that tries out the different main GUI
parts that my first program is going to use. I found the description on
how to add Alt-F4 to be able to close the application from the
keyboard. And I have implemented the abc&Xyz functionality in the
labels to have Alt-X trigger the given control. Both work perfectly in
my test application (see below).<br>
<br>
My question is regarding the Tab / Shift Tab functionality. According
to the Fox focus.html document link
above:<br>
<blockquote>Using TAB or BACK TAB. Here we simply move to the next
sibling, or if that sibling is a composite, to that composite''s first
child. At the toplevel widget we loop around so we visit all widgets
eventually tabbing around.<br>
</blockquote>
In my test program, this doesn''t work properly. When I press the Tab
key, it just circles thruogh the top 3 widgets - the 2 buttons with a
text field in between. I am not able to reach any part of the tab-book
at the bottom with the Tab key. Which to me isn''t "... visit all
widgets eventually ...".<br>
<br>
If I press Alt-1, I activate the first FXTabItem due to the label ''
Name &1 '', as expected. If I click Tab from there, the focus moves
to the second FXTabItem, also as expected. If I press Tab again, the
focus moves to the top-most button. And now we are back in the ''trapped
loop'', when I press Tab I just cycle between the 3 topmost widgets. The
Tab key is not able to get down to any FXTabItem...<br>
<br>
Is there something else needed for the Tab key to work properly in my
test program?<br>
<br>
------------ My test program: -------------------<br>
<br>
<blockquote><big><tt>require "fox16"<br>
include Fox<br>
<br>
# FXRuby version 1.6.19, precompiled version running on Windows 7<br>
# Ruby versin 1.8.6<br>
<br>
class CTMainWindow < FXMainWindow<br>
<br>
def create<br>
super<br>
show( PLACEMENT_SCREEN )<br>
end<br>
<br>
def check_close( sender, sel, data )<br>
puts "SEL_CLOSE: #{sender}"<br>
return 0<br>
end<br>
<br>
def button_pushed( sender, sel, data )<br>
puts " Button pushed:
#{sender.to_s}"<br>
end<br>
<br>
def initialize( app )<br>
super( app, "Hello from CT", :width
=> 300, :height => 200 )<br>
self.connect( SEL_CLOSE, method( :check_close )
)<br>
<br>
full_frame = FXVerticalFrame.new( self, :opts
=> FRAME_RAISED |
LAYOUT_FILL )<br>
<br>
buttonF = FXButton.new( full_frame,
"&Frame button",<br>
:opts => BUTTON_NORMAL | LAYOUT_FILL_X
)<br>
fieldF = FXTextField.new( full_frame,
20, :opts =>
LAYOUT_FILL_X )<br>
buttonG = FXButton.new( full_frame,
"&The next frame button",<br>
:opts => BUTTON_NORMAL | LAYOUT_FILL_X
)<br>
<br>
tabbook = FXTabBook.new( full_frame, :opts =>
LAYOUT_FILL )<br>
the_tab = FXTabItem.new( tabbook,
" Name &1 " )<br>
the_page = FXVerticalFrame.new(
tabbook,<br>
:opts => FRAME_RAISED | LAYOUT_FILL )<br>
<br>
the_tab2 = FXTabItem.new( tabbook,
" Name &2 " )<br>
the_page2 = FXVerticalFrame.new(
tabbook,<br>
:opts => FRAME_RAISED | LAYOUT_FILL )<br>
<br>
button1 = FXButton.new( the_page, "A
&button" )<br>
button2 = FXButton.new( the_page2,
"A¬her button" )<br>
<br>
button1.connect( SEL_COMMAND, method(
:button_pushed ) )<br>
button2.connect( SEL_COMMAND, method(
:button_pushed ) )<br>
buttonF.connect( SEL_COMMAND, method(
:button_pushed ) )<br>
buttonG.connect( SEL_COMMAND, method(
:button_pushed ) )<br>
<br>
self.accelTable.addAccel( <br>
fxparseAccel( "Alt+F4" ), self, FXSEL( SEL_CLOSE, 0 ) )<br>
end<br>
end<br>
<br>
app = FXApp.new<br>
CTMainWindow.new( app )<br>
app.create<br>
app.run<br>
<br>
</tt></big></blockquote>
------------ End of test program ----------------<br>
<br>
<br>
Best regards,<br>
Stein-Erik<br>
</body>
</html>