[fxruby-users] Handling Escape key-press in dialog window

Vladimir Konrad
Fri, 11 Jan 2008 17:04:08 -0000

Hello!

I am trying to do a log-in screen for an application and have a problem
with handling ESC key - when you press it, the dialog box closes and
the application opens. What I would like is to quit the application if
user hits ESC key while the initial log-in window is open.

The LoginWindow class looks like:

class LoginWindow < FXDialogBox

  def initialize(owner)

    super(owner, "gbrs - log in", :opts => DECOR_TITLE |
DECOR_BORDER, :width => 300, :height => 250)

    <paint the log-in window here>

    # the following code should do it but it does not

    self.accelTable.removeAccel(fxparseAccel("ESC"))
    self.accelTable.addAccel(fxparseAccel("ESC"), getApp(), \
      FXSEL(SEL_COMMAND, FXApp::ID_QUIT))
  end

end
# end of class