Onkeyd - flags in skp 2025

hello,
i face a strange problem:

while transferring my plugin to skp2025

the ruby-console shows all flags with value 0
for any key hit (notebook and external keyboard).

so nothing works in the plugin.

has anybody any idea, what is causing this?

ruby-console after hitting some keys:

TERRAIN V onKeyDown: key = 16 flags = 0
TERRAIN V onKeyDown: key = 16 flags = 0
TERRAIN V onKeyDown: key = 37 flags = 0
TERRAIN V onKeyDown: key = 40 flags = 0
TERRAIN V onKeyDown: key = 39 flags = 0
TERRAIN V onKeyDown: key = 38 flags = 0
TERRAIN V onKeyDown: key = 91 flags = 0
TERRAIN V onKeyDown: key = 16 flags = 0
TERRAIN V onKeyDown: key = 16 flags = 0
TERRAIN V onKeyDown: key = 17 flags = 0
TERRAIN V onKeyDown: key = 16 flags = 0
TERRAIN V onKeyDown: key = 17 flags = 0

code for output :
puts “bt ****onKeyDown: K:#{key} F:#{flags}”

in older skp-versions on same laptop there are flags shown and everything works well.

thanx in advance for helping

stan

You haven’t identified the extension.

Did you try installing it fresh from its source instead of copying it from the previous version?

RE, posting in correct place ...

If you are the author of the extension, please reassign this topic to the Developers > Ruby API subcategory.

EDIT: Thanx @dezmo

1 Like

hello everybody,
thanx for moving the topic to the right place.

it is my own extension and i put the whole code from the 2023 to the skp 2025 directory, as always.

the extension starts works perfectly,
just besides the detection of flags

in onkeydown.

as wrote, it is the code from api to show key and flags and
it shows always flags 0 .

like

################################################
def onKeyDown(key, repeat, flags, view)
################################################
puts “tools>grid key: #{key} flags: #{flags}”


(do ihave to use some special syntax for code snippets here ?)

so i cannot separate the keyboard keys by flags at all
as i can do it in 2018 - 2023.

as said, all skp-installations at the same laptop, so it cannot be the hardware.

so in your skp 2025 installation flags are recognized and shown without problems?

thanx
stan

As far as I know, the flags have always been broken on MS Windows for Tool#onKeyDown callbacks.

I just tested in SU17, SU23, SU24 and SU25, … and flags are still broken on MS Windows for Tool#onKeyDown callbacks.

There are several forum topics here and on SketchUcation about this.
In this one …
The flags parameter to Tool#onKeyDown and Tool#onKeyUp doesn’t make sense
… I posted links to other topics at SCF.

hi dan,
thanx a lot for the infos.

in my case flags really worked in older skp-versions,
i could separately identify ctrl and ctrl 2 , for example, and have many diffferent functions connected with them.
i will send you a small video from my previous skp-version soon.

it is unlucky, that they will not really work now. it gave me a lot of functionality.

regards
stan

Just post a code snippet please.

There are several open issues in the bug tracker from years ago:

hi dan,
the basis code:

` puts "tools>zf test-rb  key: #{key}   flags: #{flags}"

zf_test_tool_250505.rb (3.6 KB)

in 2025 i do not get any flag displayed.

in older versions i do.

thanx stan

When I said snippet, I meant a minimum module:

module ZF

  # RUN ONCE PER SESSION
  unless defined?(@loaded)
    submenu = UI.menu("Plugins").add_submenu("ZF-TEST")
    submenu.add_item("Test Ruby Tool") {
      Sketchup.active_model.select_tool(Testtool.new)
    }
    @loaded = true
  end

  class Testtool

    def initialize
      @cursor_id = 633 # Select cursor
    end ###

    def onKeyDown(key, repeat, flags, view)
      puts "onKeyDown tools>zf test-rb  key: #{key}   flags: #{flags}"
      return true
    end ###

    def onKeyUp(key, repeat, flags, view)
      puts "onKeyUp   tools>zf test-rb  key: #{key}   flags: #{flags}"
      return true
    end ###

    def onSetCursor
      UI.set_cursor(@cursor_id)
    end ###

  end # Testtool class

end # module ZF

Today I tested SU 21 … 25

onKeyDown flags
2021 yes
2022 yes
2023 no
2024 no
2025 no

But even 2021 and 2022 had goofy flags values.

I tried that module on my Mac running 2025 and still get flags. The values require some research to unpack them, but they still work. Suspecting this may have resulted from the conversion of Windows to the Qt library, I tried it on the Labs version that uses Qt on Mac. The flags don’t work there either, which seems to confirm that Qt is responsible.

1 Like

hello steve,
thanx for checking.
then it seems a win-problem, in deed.
as dan wrote, it started already with earlier version.

on my win 10 and skp 23, 25 i always get a 0 as flag, for any key combination.

that is unpleasant, since i use many keys in different combinations in my own plugin and have to change things now…unfortunately.

hipefully things get better in the future.
regards
stan

Gesendet von Outlook für Android

I’ve posted an example of using Windows system calls using Ruby’s Fiddle library: