Forum: Ruby fxruby - need help

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
faker (Guest)
on 2005-11-14 07:00
(Received via mailing list)
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
This topic is locked and can not be replied to.