Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
ImGui new thread - Page 15 — Gideros Forum

ImGui new thread

1121315171823

Comments

  • 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.
  • rrraptorrrraptor Member
    edited November 2021
    keszegh said:

    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.
  • rrraptor said:

    keszegh said:

    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)
  • keszeghkeszegh Member
    edited November 2021
    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.
  • after i click on the pen button on an imgui element then it seems that IO:wantCaptureMouse() will be true forever.

    so all in all how can i consistently stop propagation of pen/mouse events when it was on some imgui element?
  • 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.


  • hgy29hgy29 Maintainer
    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())
  • hgy29 said:

    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())

    let's see if that helps me too, thanks.
  • hgy29 said:

    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?
  • MoKaLuxMoKaLux Member
    edited November 2021
    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).
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • @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.


  • rrraptorrrraptor Member
    edited December 2021
    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)
    KeyCodes: https://github.com/MultiPain/Gideros_ImGui#available-keycodes

    I dont have free time rn to update my version.
  • thanks, in this case i'd need to disable standard inputs, how to do that?
  • rrraptorrrraptor Member
    edited December 2021
    keszegh said:

    thanks, in this case i'd need to disable standard inputs, how to do that?

    ImGui.new(nil, false, false, false)
    or just
    imgui:removeAllListeners()
  • keszeghkeszegh Member
    edited December 2021
    @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.type then print(event.type.."  "..event.touch.mouseButton) end
        lastEv=event.type
    end
    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)
  • MoKaLuxMoKaLux Member
    edited December 2021
    I can't seem to use imageButton pressed :/
    I tried this but it doesn't work for me:
    pressed = imgui:imageButton(Texture.new("gfx/100 (2).png", true), 100, 100)
    print(pressed)
     
    if imgui:imageButton(Texture.new("gfx/100 (2).png", true), 120, 120, 64, 0xffffff, 1, 0xff0000, 1) then
    	print(e.deltaTime)
    end
    Also in gideros github I see this:
    int ImageButton(lua_State* L)
    {
    	STACK_CHECKER(L, "imageButton", 1);
     
    	GTextureData data(L, 2);
    	const ImVec2& size = ImVec2(luaL_checknumber(L, 3), luaL_checknumber(L, 4));
    	int frame_padding = luaL_optinteger(L, 5, -1);
    	const ImVec4& tint = GColor::toVec4(luaL_optinteger(L, 6, 0xffffff), luaL_optnumber(L, 7, 1.0f));
    	const ImVec4& bg_col = GColor::toVec4(luaL_optinteger(L, 8, 0xffffff), luaL_optnumber(L, 9, 0.0f));
     
    	setupUVs(L, data, 10);
     
    	lua_pushboolean(L, ImGui::ImageButton(data.texture, size, data.uv0, data.uv1, frame_padding, bg_col, tint));
    	return 1;
    }
    Shouldn't it be:
    	const ImVec4& bg_col = GColor::toVec4(luaL_optinteger(L, 6, 0xffffff), luaL_optnumber(L, 7, 0.0f));
    	const ImVec4& tint = GColor::toVec4(luaL_optinteger(L, 8, 0xffffff), luaL_optnumber(L, 9, 1.0f));
    Aren't tint and bg_col somehow inverted!, 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 :) )
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLux said:

    I can't seem to use imageButton pressed :/
    I tried this but it doesn't work for me:

    pressed = imgui:imageButton(Texture.new("gfx/100 (2).png", true), 100, 100)
    print(pressed)
     
    if imgui:imageButton(Texture.new("gfx/100 (2).png", true), 120, 120, 64, 0xffffff, 1, 0xff0000, 1) then
    	print(e.deltaTime)
    end
    Also in gideros github I see this:
    int ImageButton(lua_State* L)
    {
    	STACK_CHECKER(L, "imageButton", 1);
     
    	GTextureData data(L, 2);
    	const ImVec2& size = ImVec2(luaL_checknumber(L, 3), luaL_checknumber(L, 4));
    	int frame_padding = luaL_optinteger(L, 5, -1);
    	const ImVec4& tint = GColor::toVec4(luaL_optinteger(L, 6, 0xffffff), luaL_optnumber(L, 7, 1.0f));
    	const ImVec4& bg_col = GColor::toVec4(luaL_optinteger(L, 8, 0xffffff), luaL_optnumber(L, 9, 0.0f));
     
    	setupUVs(L, data, 10);
     
    	lua_pushboolean(L, ImGui::ImageButton(data.texture, size, data.uv0, data.uv1, frame_padding, bg_col, tint));
    	return 1;
    }
    Shouldn't it be:
    	const ImVec4& bg_col = GColor::toVec4(luaL_optinteger(L, 6, 0xffffff), luaL_optnumber(L, 7, 0.0f));
    	const ImVec4& tint = GColor::toVec4(luaL_optinteger(L, 8, 0xffffff), luaL_optnumber(L, 9, 1.0f));
    Aren't tint and bg_col somehow inverted!, 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 :) )
    No problems for me :/
    MoKaLux said:

    fixed one bug :)

    	ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f));
    //	ImGui::SetNextWindowSize(IO.DisplaySize); bug XXX
        ImGui::SetNextWindowSize(ImVec2(0.0f, 0.0f));
    Will try to find/fix some more and commit to gideros github.
    How is that a bug?
    IO.DisplaySize is ImVec2, SetNextWindowSize expects ImVec2 too, so ... ?

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • rrraptorrrraptor Member
    edited December 2021
    So it doesnt work because you are calling Texture constructor in enter frame. If you cache it, it works.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited December 2021
    Oh nevermind ALL my latest posts :# everything is working now, I don't know what happened :s
    Sorry for the inconveniences :(


    It was fun though looking at some c++/lua bindings, think I have learnt some things ;)
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • rrraptorrrraptor Member
    edited December 2021
    MoKaLux said:

    I tried SetNextWindowSize but it wouldn't work for me, that's why I though this was a bug, does it work for you?

    Yes
    if (ui:beginFullScreenWindow("Main", nil, MAIN_WINDOW_FLAGS)) then
    	self:onDrawUI()
    	ui:endWindow()
    end
    Same:
    ui:setNextWindowPos(ui:getPosition())
    ui:setNextWindowSize(self.io:getDisplaySize())
     
    ui:pushStyleVar(ImGui.StyleVar_WindowRounding, 0)
    if (ui:beginWindow("Main", nil, MAIN_WINDOW_FLAGS)) then
    	ui:popStyleVar()
    	self:onDrawUI()
    	ui:endWindow()
    end

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • keszeghkeszegh Member
    edited December 2021
    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
  • keszeghkeszegh Member
    edited December 2021
    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)
  • written over the original dll with the pre_build one and putting
    require "ImGui_pre_build", for me it crashes without any error message.
  • by writing
    require "ImGui", it crashed with the old error message. i thought in this case it should give some error not finding the requirement.
  • keszegh said:

    written over the original dll with the pre_build one and putting
    require "ImGui_pre_build", for me it crashes without any error message.

    any help? ty
  • keszegh said:


    keszegh said:

    written over the original dll with the pre_build one and putting
    require "ImGui_pre_build", for me it crashes without any error message.

    any help? ty
    No, works for me...
    Dbgview empty?
  • debugview:
    [8988] Deleted program:3
    [8988] Deleted program:6
    [8988] Deleted program:9
    [8988] Deleted program:12
    [8988] Deleted program:15
    [8988] Deleted program:21
    [8988] Deleted program:27
    [8988] Deleted program:30
    [8988] Deleted program:33
    [8988] GL Version 4.600000 (Desktop)
    [8988] GL_VERSION:4.6.0 NVIDIA 471.96
    [8988] 
    [8988] GLSL_VERSION:4.60 NVIDIA
    [8988] 
    [8988] [S_API FAIL] SteamAPI_Init() failed; no appID found.
    [8988] Either launch the game from Steam, or put the file steam_appid.txt containing the correct appID in your game folder.
    [8988] Deleted program:3
    [8988] Deleted program:6
    [8988] Deleted program:9
    [8988] Deleted program:12
    [8988] Deleted program:15
    [8988] Deleted program:27
    [8988] Deleted program:33
    [8988] Deleted program:37
    [8988] Deleted program:40
    [8988] GL Version 4.600000 (Desktop)
    [8988] GL_VERSION:4.6.0 NVIDIA 471.96
    [8988] 
    [8988] GLSL_VERSION:4.60 NVIDIA
    [8988] 
    [8988] [S_API FAIL] SteamAPI_Init() failed; no appID found.
    [8988] Either launch the game from Steam, or put the file steam_appid.txt containing the correct appID in your game folder.
    [7452] 14:36:24.323  8   AudioDeviceSession OnStateChanged Inactive GiderosPlayer {0.0.0.00000000}.{c7c7e722-72dc-4179-9a88-f2b23710d84f}|\Device\HarddiskVolume4\Program Files (x86)\Gideros\GiderosPlayer.exe%b{00000000-0000-0000-0000-000000000000}|1%b8988 
    [7452] 14:36:24.340  7   ProcessWatcherService Quit: 8988 
    [7452] 14:36:24.340  7   AudioDeviceSession DisconnectSession GiderosPlayer {0.0.0.00000000}.{c7c7e722-72dc-4179-9a88-f2b23710d84f}|\Device\HarddiskVolume4\Program Files (x86)\Gideros\GiderosPlayer.exe%b{00000000-0000-0000-0000-000000000000}|1%b8988 
    [7452] 14:36:24.344  8   AudioDeviceSession OnStateChanged Expired GiderosPlayer {0.0.0.00000000}.{c7c7e722-72dc-4179-9a88-f2b23710d84f}|\Device\HarddiskVolume4\Program Files (x86)\Gideros\GiderosPlayer.exe%b{00000000-0000-0000-0000-000000000000}|1%b8988 
    [7452] 14:36:24.344 UI AudioDeviceSessionCollection RemoveSession GiderosPlayer {0.0.0.00000000}.{c7c7e722-72dc-4179-9a88-f2b23710d84f}|\Device\HarddiskVolume4\Program Files (x86)\Gideros\GiderosPlayer.exe%b{00000000-0000-0000-0000-000000000000}|1%b8988
Sign In or Register to comment.