Closed mrg0lden closed 3 years ago
It's because of this: https://github.com/c-smile/sciter-sdk/blob/master/include/sciter-x-behavior.h#L73
So I need to unmask it manually before checking its type, correct?
Correct.
Technically, we could introduce a separate params.Phase()
and keep params.Cmd()
clean: https://github.com/sciter-sdk/go-sciter/blob/ce0e920fd2fb79974c2cc202242fba2f774559c0/types.go#L588-L590
I think that'd be better because it's quite confusing now.
Hi, I tried to attach a behavior event handler on an element. When I tried to check its type by comparing it to existing enums, It didn't match the supposed types. Doing some investigations, I found that the 16th bit is set, so instead of (binary)
100
it becomes10000000000100
.Code Example
input is a *sciter.Element ### This code doesn't work ```go //... input.AttachEventHandler(&sciter.EventHandler{ OnBehaviorEvent: func(target *sciter.Element, params *sciter.BehaviorEventParams) bool { cmd := uint32(params.Cmd()) if cmd == uint32(sciter.EDIT_VALUE_CHANGED) { fmt.Println("It works, it seems") } fmt.Printf("%d %X %b\n", cmd, cmd, cmd) return true }, }) //... ``` ```go input.AttachEventHandler(&sciter.EventHandler{ OnBehaviorEvent: func(target *sciter.Element, params *sciter.BehaviorEventParams) bool { cmd := uint32(params.Cmd()) leading := bits.LeadingZeros32(cmd) cmd ^= (1 << (31 - uint32(leading))) //remove leading set bit if cmd == uint32(sciter.EDIT_VALUE_CHANGED) { fmt.Println("It works, it seems") } fmt.Printf("%d %X %b\n", cmd, cmd, cmd) return true }, }) ````Is this a normal behavior?