fxruby - need help

S

soxinbox

I am just starting to use fxruby, so this might be a dumb question.
I am having trouble with hiding and showing buttons and text field.
It seems that when I show a button or text field that was hidden, the button
is placed randomly, usually under the other objects, and the text doesn't
show up at all. When I resize the window by grabbing the corner, they both
snap to the correct locations. I have tried forceRefresh, recalc, repaint,
and a few others, but nothing seems to help. I have included a very short
example of the problem below.

#/usr/bin/env ruby
require 'fox14'
include Fox
class PlotterWindow < FXMainWindow
def initialize(app)
# Invoke base class initialize first
super(app, "Plotter", nil, nil, DECOR_ALL, 0, 0, 300, 300)

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# INITIALIZE #
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
FXToolTip.new(self.getApp())
statusbar = FXStatusBar.new(self,
LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|STATUSBAR_WITH_DRAGCORNER)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# LAYOUT #
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
showButton = FXButton.new(self,
"Show\tShow the BLAH Button\tMake BLAH button visable",
nil, nil, 0,
LAYOUT_SIDE_TOP|FRAME_RAISED|FRAME_THICK|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,40,
40, 70, 30)
hideButton = FXButton.new(self,
"Hide\tHide the BLAH Button\tMake BLAH button hidden",
nil, nil, 0,
LAYOUT_SIDE_TOP|FRAME_RAISED|FRAME_THICK|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,40,
40, 70, 30)
blahButton = FXButton.new(self,
"BLAH!!\tBLAH BUTTON\tThe BLAH button has no action",
nil, nil, 0,
LAYOUT_SIDE_TOP|FRAME_RAISED|FRAME_THICK|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT,40,
40, 70, 30)
blahButton.hide
myTextField = FXTextField.new(self, 20, NIL, 0,
LAYOUT_SIDE_BOTTOM|FRAME_SUNKEN|FRAME_THICK|TEXTFIELD_READONLY)
myTextField.setText("blah blah blah!")
myTextField.hide
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# ACTIOINS #
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
showButton.connect(SEL_COMMAND) {
print "SHOW!\n"
STDOUT.flush
blahButton.show
myTextField.show
1
}
hideButton.connect(SEL_COMMAND) {
print "HIDE!\n"
STDOUT.flush
blahButton.hide
myTextField.hide
1
}
end
def create
super
show(PLACEMENT_SCREEN)
end
end

if __FILE__ == $0
# Construct an application
application = FXApp.new("Button", "FoxTest")
# Construct the main window
PlotterWindow.new(application)
# Create the application
application.create
# Run it
application.run
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top