Overlapping controls disables mouse input
Posted: 18 Sep 2021, 07:58
I just noticed that I cant use the mouse to select controls that are overlapping when both are drawn properly but if only one of them is drawn properly and the other first appears when the mouse is over it then I can click it. Here is the example that is giving me trouble https://github.com/CapnOdin/GridGUI/blob/master/Examples/Example%20Background.ahk
If changed to the below then it can be interacted with using the mouse but it is drawn wrong.
I have looked at https://autohotkey.com/board/topic/20542-solved-making-overlapping-controls-respond-to-mouse-clicks/ but it requires that I manually redraw the controls in the correct order, or at least that is how I understand it.
Edit: it seems to be related to my lib as when I try to reproduce it without it then I get no issue with mouse input
Edit 2: If I add the picture the normal way that is using the Gui command instead of using my lib then it works without problem, I wonder what I am doing wrong.
Edit 3: It is odd, I don't think that my lib does anything to the controls besides calling GuiControl, MoveDraw with some calculated positions and sizes in the order that the controls were added, although it does this each time the GUI is resized.
Edit 4: Could it be due to the OnMessage callbacks that I set up, I am using WM_SIZE, WM_MOVE, WM_ACTIVATE, WM_CONTEXTMENU, WM_SYSCOMMAND and WM_DROPFILES.
Edit 5: It seems to not be connected to the OnMessage callbacks.
Edit 6: I have implemented a workaround but the core issue is still unknown to me. The workaround involves registering the controls that should be shown ontop of the background control and drawing them later a second time like was done in the link I mentioned.
If changed to the below then it can be interacted with using the mouse but it is drawn wrong.
Code: Select all
#Include %A_ScriptDir%\..\GridGUI.ahk
myGui := new GridGUI("Grid Test", "resize")
myGui.GuiClose := GridGUI.ExitApp
oWB := myGui.Add(3, "2-3", "ActiveX", "w113 h43", "shell explorer").vVar
oWB.Navigate("about:<!DOCTYPE HTML><html><body style=""{margin:0;}""><img src=""https://i.imgur.com/FlGrIY3.gif""></body></html>")
oWB.document.body.style.overflow := "hidden"
myGui.Add("1-3", 1, "Edit", , , 1, , 1)
myGui.Add(1, 2, "Button", , "Button")
myGui.Add(2, 2, "Edit", "w0", , 1, 1, 1)
myGui.Add(1, 3, "Button", , "Button")
myGui.Add(2, "3-4", "Button", , "Button Button", , 1)
myGui.Add("1-3", 5, "Button", , "Button", 1, , 1)
ctrl := myGui.Add("1-3", "1-5", "Picture", "w0 h0", "Images\background.png", , , 1, 1)
myGui.Show()
return
Edit: it seems to be related to my lib as when I try to reproduce it without it then I get no issue with mouse input
Edit 2: If I add the picture the normal way that is using the Gui command instead of using my lib then it works without problem, I wonder what I am doing wrong.
Edit 3: It is odd, I don't think that my lib does anything to the controls besides calling GuiControl, MoveDraw with some calculated positions and sizes in the order that the controls were added, although it does this each time the GUI is resized.
Edit 4: Could it be due to the OnMessage callbacks that I set up, I am using WM_SIZE, WM_MOVE, WM_ACTIVATE, WM_CONTEXTMENU, WM_SYSCOMMAND and WM_DROPFILES.
Edit 5: It seems to not be connected to the OnMessage callbacks.
Edit 6: I have implemented a workaround but the core issue is still unknown to me. The workaround involves registering the controls that should be shown ontop of the background control and drawing them later a second time like was done in the link I mentioned.