In the sample program below I have a form of 6 text fields, in a scrolling
window, followed by a row of function buttons.
Problems:
1) For data entry purposes I''d like the function buttons NOT to be
entered
by pressing Tab keys, and retain their ''clickability'', but
when the user
Tab''s out of the last scrolling field (postcode) to have the form
scroll to
the top and the cursor positioned in the first field to accept a new set of
data.
The scrolling works, but the focus moves to the first Button and not the
field even tho I have a explicit setFocus. I dont want the Buttons
''hidden''
just not tabbable -- is this possible?
2) if no data is entered into a field prior to a Tab press, the scroller
does not scroll the form at all, the cursor moves to next field OK, but I
never get to see the off scrollwindow fields. If I enter some data, then
Tab, the scroller functions
and the next fields are displayed.
Thanks
=============================================#!/usr/bin/env ruby
# zestaddr2.rb
# Generated by RubyFXGen.rb Ver 0.9a on :Mon Sep 01 17:20:31 +1000 2008
# plus added code to setup scroller
require ''fox16''
include Fox
class MainWindow < FXMainWindow
def initialize(app) super( app, ''Zest Address Entry'')
self.width = 422
self.height = 250
amain= FXVerticalFrame.new(self,LAYOUT_NORMAL|LAYOUT_FILL_X|LAYOUT_FILL_Y)
main = FXScrollWindow.new(amain, LAYOUT_FILL_X|LAYOUT_FILL_Y)
addr= FXMatrix.new(main, 2,MATRIX_BY_COLUMNS|LAYOUT_CENTER_X)
# addr
FXLabel.new(addr, "First Name" ,
nil,LABEL_NORMAL|LAYOUT_FILL_X|LAYOUT_FILL_Y)
fld1= FXDataTarget.new("")
fld1a=FXTextField.new(addr,20, fld1, FXDataTarget::ID_VALUE,
FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y)
fld1a.connect(SEL_COMMAND) do
puts "fld1 contains #{fld1.value}"
main.setPosition(-10, -10)
end
FXLabel.new(addr, "Surname" ,
nil,LABEL_NORMAL|LAYOUT_FILL_X|LAYOUT_FILL_Y)
fld2= FXDataTarget.new("")
FXTextField.new(addr,20, fld2, FXDataTarget::ID_VALUE,
FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y)
fld2.connect(SEL_COMMAND) do
puts "fld2 contains #{fld2.value}"
main.setPosition(-20, -20)
end
FXLabel.new(addr, "Company Name" ,
nil,LABEL_NORMAL|LAYOUT_FILL_X|LAYOUT_FILL_Y)
fld3= FXDataTarget.new("")
FXTextField.new(addr,20, fld3, FXDataTarget::ID_VALUE,
FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y)
fld3.connect(SEL_COMMAND) do
puts "fld3 contains #{fld3.value}"
main.setPosition(-30, -30)
end
FXLabel.new(addr, "Addr1" ,
nil,LABEL_NORMAL|LAYOUT_FILL_X|LAYOUT_FILL_Y)
addr1= FXDataTarget.new("")
FXTextField.new(addr,20, addr1, FXDataTarget::ID_VALUE,
FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y)
addr1.connect(SEL_COMMAND) do
puts "addr1 contains #{addr1.value}"
main.setPosition(-40, -40)
end
FXLabel.new(addr, "Addr2" ,
nil,LABEL_NORMAL|LAYOUT_FILL_X|LAYOUT_FILL_Y)
addr2= FXDataTarget.new("")
FXTextField.new(addr,20, addr2, FXDataTarget::ID_VALUE,
FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y)
addr2.connect(SEL_COMMAND) do
puts "addr2 contains #{addr2.value}"
main.setPosition(-50, -50)
end
FXLabel.new(addr, "Addr3" ,
nil,LABEL_NORMAL|LAYOUT_FILL_X|LAYOUT_FILL_Y)
addr3= FXDataTarget.new("")
FXTextField.new(addr,20, addr3, FXDataTarget::ID_VALUE,
FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y)
addr3.connect(SEL_COMMAND) do
puts "addr3 contains #{addr3.value}"
main.setPosition(-70, -70)
end
FXLabel.new(addr, "PostCode" ,
nil,LABEL_NORMAL|LAYOUT_FILL_X|LAYOUT_FILL_Y)
postcode= FXDataTarget.new("")
FXTextField.new(addr,20, postcode, FXDataTarget::ID_VALUE,
FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y)
postcode.connect(SEL_COMMAND) do
puts "postcode contains #{postcode.value}"
main.setPosition(-0, -0) ## scroll back to first field ( it does )
fld1a.setFocus ## focus on first field ( it does NOT !
-> first BUTTON "New" )
end
btns= FXHorizontalFrame.new(amain, LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN)
# btns
new= FXButton.new(btns, "New", :opts => LAYOUT_FILL_X|
BUTTON_NORMAL)
new.connect(SEL_COMMAND) do |sender, sel, checked|
# ## your button press code here ##
end # new
clear= FXButton.new(btns,"Clear", :opts =>
LAYOUT_FILL_X|BUTTON_NORMAL)
clear.connect(SEL_COMMAND) do |sender, sel, checked|
# ## your button press code here ##
end # clear
load= FXButton.new(btns,"Load", :opts=>
LAYOUT_FILL_X|BUTTON_NORMAL)
load.connect(SEL_COMMAND) do |sender, sel, checked|
# ## your button press code here ##
end # load
save= FXButton.new(btns,"Save", :opts=>LAYOUT_FILL_X|BUTTON_NORMAL)
save.connect(SEL_COMMAND) do |sender, sel, checked|
# ## your button press code here ##
end # save
quit= FXButton.new(btns,"Quit", :opts=>LAYOUT_FILL_X|BUTTON_NORMAL)
quit.connect(SEL_COMMAND) do |sender, sel, checked|
# ## your button press code here ##
exit()
end # quit
# set initial field address
fld1a.setFocus
end # def initilize
def create
super
show(PLACEMENT_SCREEN)
end # create
end # class MainWindow
# ============= main prog ============
# Construct an application
theApp = FXApp.new(''Smithy'',''Max'')
# Construct the main window
theApp.normalFont = FXFont.new(theApp,''Adobe
Courier'',12,FONTWEIGHT_BOLD)
# define default display FONT for this application
MainWindow.new(theApp)
# Create and show the application windows
theApp.create
# Run the application
theApp.run
# ============= end ============
--
View this message in context:
http://www.nabble.com/Tab-control-using-FXRuby-tp19343124p19343124.html
Sent from the FXRuby Users mailing list archive at Nabble.com.