Skip to content

Apparent erroneous key event behaviour under Windows #42

Description

@hesychius

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions