now a (pen) touch event generates a mouse event, which is handled by imgui. but also there is the pen event which is handled behind in my drawing area. how can i prevent this? can i somehow stop eventpropagation of the touch event if imgui 'got it' as a mouse event?
perhaps the hovering thing is also a problem in gideros? @hgy29 ? i shall test later.
Because tablet events treated as touch events which only triggers if something is touching the screen or tablet in your case.
yes, actually would be more logical for gideros to treat pen events as mouse events and not as touch events. (As there is only one pen anyway so multitouch is not needed)
so i'm having this issue with how to stop propagation of event. i used IO:wantCaptureMouse() but now with mouse/touch invoking the other i have an issue that the event pressing the imgui button is a touch event even behind the button on my gideros object when IO:wantCaptureMouse() is still false. how can i prevent this?
in particular, in the Constructor i've noticed a touch_listeners thing: ImGui.new([font_atlas = nil, mouse_listeners = true, keyboard_listeners = true, touch_listeners = false])
what happens if i set it true? i thought that maybe then i won't need that touch events create mouse events, but it is not the case.
so i'm stuck with how to prevent getting touch info for an imgui related event.
i think the problem is that the touches_down event happens first, my drawing layer registers it. then only afterwards it propagates a mouse event which imgui gets and sets wantCaptureMouse() properly, but too late as before this there is no way to know that the touch event is for imgui. one solution would be for imgui to handle touch events already (and then i do not need to propagate a mouse event from a touch event). other solution would be if when touch event propagates a mouse event, it would also transfer the 'type', 'pressure' etc info and then in my app i can listen only to mouse events (which would properly not get to my background sprite if imgui captures it).
so, @hgy29 , @rrraptor , any ideas how should i handle this issue? thanks, i appreciate your efforts with this annoying wacom pen issue.
I'll add a mouseType in the mouse events, similar to the touchType, to help detect synthesized mouse events. BTW I'll add the whole pressed button set in tablet move events (buttons() in QT instead of button())
I'll add a mouseType in the mouse events, similar to the touchType, to help detect synthesized mouse events. BTW I'll add the whole pressed button set in tablet move events (buttons() in QT instead of button())
I'll add a mouseType in the mouse events, similar to the touchType, to help detect synthesized mouse events. BTW I'll add the whole pressed button set in tablet move events (buttons() in QT instead of button())
is it possible to add hover type event too when pen is hovering?
FYI navigation between input textfields seems to be broken? tab goes to the next input textfield OK shift+tab doesn't go to the previous input textfield NOT OK
EDIT: that works in html5, it didn't work (for me) on windows 10 (it behaves very strangely on my windows 10).
@rrraptor , @hgy29 please help. so with latest version 2021.11: in my background sprite i just listen to mouse events for simplicity (and touch events propagate mouse events too) whenever i press right button of pen (windows ink on) on some imgui element then it triggers the right-click event of the imgui element fine. yet, it also sends a mouse_down event to my sprite below, so the event is not stopped from propagation (When i do the same with the mouse, that is, right-click with a mouse on imgui, then it correctly does not reach my background sprite). even more seriously, starting with this there is no mousedown event ever reaching my sprite when i put pen down again and again. this error can be corrected e.g. if i right-click with mouse somewhere on my background. so overall windows ink on it is completely unusable at the moment, yet this is the only mode when i could get pressure info.
Technichally, you can implement input system by yourself using this functions:
-- set ALT/SHIFT/CTRL/SUPER (META) key state
IO:setModKeyDown(key_code, bool)-- set key state
IO:setKeysDown(key_code, bool)-- adds text to active text input widget
IO:addInputCharactersUTF8(text)-- emulate wheel scrolling
IO:setMouseWheel(number)-- sets mouse position (data only, no visual changes)
IO:setMousePos(x, y)-- set mouse state, where index: 0 - left mouse, 1 - right, 2 - middle, 3 - unused, 4 - unused.
IO:setMouseDown(index, state)
@rrraptor , i think i have something that may help to correct the issue finally: so setting self.imgui = ImGui.new(nil, true, true, false) (and touch events generate mouse events and vice versa) if i add print(self.imgui:isMouseDown(2)) to onEnterFrame then if i press pen button then it becomes true yet when i release it then it does not go back to false UNLESS i move the pen like 1 cm away from where i pressed it.
let me also copy-paste the same issue from gideros side i wrote on another thread (here one can see that at least gideros noticed the event when penbutton is released, it just misinterprets it and thinks that the pen was released and not the penbutton (i.e. mouseButton=1 instead of =2):
@hgy29 , i'm trying to test wacom and imgui etc. one anomaly that may affect my issues is the following (no imgui at all in this example):
if on touch events i have:
function onTouch(event)if lastEv~=event.typethenprint(event.type.." "..event.touch.mouseButton)end
lastEv=event.typeend
then if i press right-button of pen and move it and release, i get "touchesBegin 2" "touchesMove 2" "touchesEnd 2"
yet if i just press it and don't move it or just move it a little and then release it, i get "touchesBegin 2" "touchesMove 2" "touchesEnd 1"
so the end event has wrong button info. this may be related to the issue where 'touchesEnd' event is missing completely when used together with imgui i wrote about earlier. perhaps if this would be corrected, then it would improve my case.
and because of this IO:wantCaptureMouse() also remains true after the penbutton is released without moving at least ~1cm (which sadly is usually the case when one presses an item in imgui)
i try to use setMouseDown() etc. to manually set positions and buttons, but i get the following error: calling 'setMousePos' on bad self (ImGui expected, got table)
and the code i use:
local IO = gui.imgui:getIO()if event.type=="touchesBegin"then
IO:setMousePos(event.touch.x, event.touch.x)
IO:setMouseDown(event.touch.mouseButton, true)end
somehow in the source code of imgui i cannot find setMousePos to see the syntax, so i'm stuck. EDIT: i've found it in the source but it does not help me to understand the issue (and if i'm doing something wrong or there is a bug in the imgui code). thanks for the help @rrraptor
i'vre tried the following code which is almost the same you posted in another thread a while ago and it has the same crash and error: main.lua:27: calling 'setMousePos' on bad self (ImGui expected, got table)
require"ImGui"local ui = ImGui.new(false,false, false, false)-- disable all events--ui:setResetTouchPosOnEnd(true) -- if enabled resets touch pos to INF on "touchesEnd" event.local IO = ui:getIO()
IO:setMouseDrawCursor(true, false)-- draw cursor, without hiding system cursor (second arg)
stage:addChild(ui)
stage:addEventListener("enterFrame", function(e)
ui:newFrame(e.deltaTime)
ui:showDemoWindow()
ui:render()
ui:endFrame()end)-- imgui_button_index: 0 to 4 (int)-- state: bool-- IO:setMouseDown(imgui_button_index, state)-- IO:setMousePos(x, y)-- IO:setMouseWheel(value)
stage:addEventListener("touchesBegin", function(e)local x, y = e.touch.x, e.touch.y
IO:setMouseDown(0, true)
IO:setMousePos(x, y)end)
stage:addEventListener("touchesMove", function(e)local x, y = e.touch.x, e.touch.y
IO:setMouseDown(0, true)
IO:setMousePos(x, y)end)
stage:addEventListener("touchesEnd", function(e)local x, y = e.touch.x, e.touch.y
IO:setMouseDown(0, false)
IO:setMousePos(x, y)end)
Comments
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game
in particular, in the Constructor i've noticed a touch_listeners thing:
ImGui.new([font_atlas = nil, mouse_listeners = true, keyboard_listeners = true, touch_listeners = false])
what happens if i set it true? i thought that maybe then i won't need that touch events create mouse events, but it is not the case.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
so all in all how can i consistently stop propagation of pen/mouse events when it was on some imgui element?
Fragmenter - animated loop machine and IKONOMIKON - the memory game
i think the problem is that the touches_down event happens first, my drawing layer registers it. then only afterwards it propagates a mouse event which imgui gets and sets wantCaptureMouse() properly, but too late as before this there is no way to know that the touch event is for imgui.
one solution would be for imgui to handle touch events already (and then i do not need to propagate a mouse event from a touch event).
other solution would be if when touch event propagates a mouse event, it would also transfer the 'type', 'pressure' etc info and then in my app i can listen only to mouse events (which would properly not get to my background sprite if imgui captures it).
so, @hgy29 , @rrraptor , any ideas how should i handle this issue?
thanks, i appreciate your efforts with this annoying wacom pen issue.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
BTW I'll add the whole pressed button set in tablet move events (buttons() in QT instead of button())
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game
navigation between input textfields seems to be broken?
tab goes to the next input textfield OK
shift+tab doesn't go to the previous input textfield NOT OK
EDIT: that works in html5, it didn't work (for me) on windows 10 (it behaves very strangely on my windows 10).
in my background sprite i just listen to mouse events for simplicity (and touch events propagate mouse events too)
whenever i press right button of pen (windows ink on) on some imgui element then it triggers the right-click event of the imgui element fine. yet, it also sends a mouse_down event to my sprite below, so the event is not stopped from propagation (When i do the same with the mouse, that is, right-click with a mouse on imgui, then it correctly does not reach my background sprite). even more seriously, starting with this there is no mousedown event ever reaching my sprite when i put pen down again and again. this error can be corrected e.g. if i right-click with mouse somewhere on my background.
so overall windows ink on it is completely unusable at the moment, yet this is the only mode when i could get pressure info.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
I dont have free time rn to update my version.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
so setting self.imgui = ImGui.new(nil, true, true, false)
(and touch events generate mouse events and vice versa)
if i add print(self.imgui:isMouseDown(2)) to onEnterFrame then
if i press pen button then it becomes true yet when i release it then it does not go back to false UNLESS i move the pen like 1 cm away from where i pressed it.
let me also copy-paste the same issue from gideros side i wrote on another thread (here one can see that at least gideros noticed the event when penbutton is released, it just misinterprets it and thinks that the pen was released and not the penbutton (i.e. mouseButton=1 instead of =2):
@hgy29 , i'm trying to test wacom and imgui etc. one anomaly that may affect my issues is the following (no imgui at all in this example):
if on touch events i have:
"touchesBegin 2"
"touchesMove 2"
"touchesEnd 2"
yet if i just press it and don't move it or just move it a little and then release it, i get
"touchesBegin 2"
"touchesMove 2"
"touchesEnd 1"
so the end event has wrong button info. this may be related to the issue where 'touchesEnd' event is missing completely when used together with imgui i wrote about earlier. perhaps if this would be corrected, then it would improve my case.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game
I tried this but it doesn't work for me:
maybe that's why it isn't working?EDIT: I have built a test dll with changes above done and it seems to be working (but not the press button yet, I am investigating )
How is that a bug?
IO.DisplaySize is ImVec2, SetNextWindowSize expects ImVec2 too, so ... ?
Likes: MoKaLux
Likes: MoKaLux
Sorry for the inconveniences
It was fun though looking at some c++/lua bindings, think I have learnt some things
Likes: MoKaLux
calling 'setMousePos' on bad self (ImGui expected, got table)
and the code i use:
thanks for the help @rrraptor
Fragmenter - animated loop machine and IKONOMIKON - the memory game
main.lua:27: calling 'setMousePos' on bad self (ImGui expected, got table)
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: keszegh
require "ImGui_pre_build", for me it crashes without any error message.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
require "ImGui", it crashed with the old error message. i thought in this case it should give some error not finding the requirement.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Dbgview empty?
Fragmenter - animated loop machine and IKONOMIKON - the memory game