To wrap up this introduction, we'd like to add a few finishing touches to the program. The first addition is to add a tool tip to the button, such that when the mouse cursor hovers over the button for a short while, it will pop up a little message describing what the button does:
require 'fox14' include Fox theApp = FXApp.new theMainWindow = FXMainWindow.new(theApp, "Hello") theButton = FXButton.new(theMainWindow, "Hello, World!") theButton.tipText = "Push Me!" theButton.connect(SEL_COMMAND) { exit } FXToolTip.new(theApp) theApp.create theMainWindow.show theApp.run
There are two changes involved here. The first is to set the tool
tip text for the button using the tipText
accessor, and for this example we're setting the button's tip text to
"Push Me!". The second change is to create the (single)
FXToolTip
instance for the application. Although
this program shows the FXToolTip
instance being
created after the FXButton
, it doesn't really
matter when you do it. You just want to have instantiated the
FXToolTip
before you drop into the main event loop
by calling FXApp#run
. If you run this version and
hover over the button for a second or so, you should see the tooltip pop
up: