larskanis / fxruby

FXRuby is an extension module for Ruby that provides an interface to the FOX GUI toolkit.

Home Page:http://rubydoc.info/gems/fxruby/frames

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Apparent erroneous key event behaviour under Windows

hesychius opened this issue · comments

Key events are being reported inconsistently (and I believe incorrectly) under Windows. The test program below illustrates the problem.

#!/usr/bin/env ruby
require 'fox16'
include Fox

class TopLevelWindow < FXMainWindow
   def initialize(app)
      super(app, 'Test Application', :width => 400, :height => 200)
      p = FXPacker.new(self, :opts => FRAME_SUNKEN|LAYOUT_FILL)
      t = FXTextField.new(p, 20, :opts => LAYOUT_FILL_X)
      @text_widget =
         FXText.new(p, :opts => TEXT_WORDWRAP|TEXT_READONLY|LAYOUT_FILL)

      t.connect(SEL_KEYPRESS) do |sender, selector, event|
         @text_widget.appendText "press\t#{'%x'%event.code} [#{event.state}]\n"
         @text_widget.makePositionVisible(@text_widget.getBottomLine)
         false
      end

      t.connect(SEL_KEYRELEASE) do |sender, selector, event|
         @text_widget.appendText "release\t#{'%x'%event.code} [#{event.state}]\n"
         @text_widget.makePositionVisible(@text_widget.getBottomLine)
      end
   end

   def create
      super
      show(PLACEMENT_SCREEN)
   end
end

This program provides a text field on top and a text widget on the bottom. When text is entered in the text field, the key events are displayed below. Testing under FreeBSD (and I would assume other types of Unix/Linux) gives the expected results, but under Windows, it behaves inconsistently:

  • Letters work correctly - 'a' shows up as event code 0x61 and 'A' as 0x41, as expected
  • Other characters do not show the shifted value - "'" (single quote) shows up as 0x27, but '"' also shows up as 0x27, not the expected value 0x22 for a double-quote symbol.