Overlapping controls disables mouse input Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Overlapping controls disables mouse input

Post by Capn Odin » 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.

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
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.
Please excuse my spelling I am dyslexic.
User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

Re: Overlapping controls disables mouse input  Topic is solved

Post by Hellbent » 18 Sep 2021, 16:34

Here are a few examples of overlapping control problems and solutions.

Not sure if any of it is helpful.

Code: Select all


#SingleInstance, Force

Gui, 1:New, +AlwaysOnTop

;*************************************************************************************


Gui, 1:Add, Progress, cRed,100
Gui, 1:Add, Text, xp yp wp hp gTest BackgroundTrans Center, Button

Gui, 1:Add, Progress, cLime Disabled,100
Gui, 1:Add, Text, xp yp wp hp gTest BackgroundTrans Center, Button


;********************************************************************************

Gui, 1:Add, Text, wp hp gTest
Gui, 1:Add, Progress, xp yp wp hp cBlue,100
Gui, 1:Add, Progress, xp yp+3 wp hp-3 backgroundBlack cAqua,100
Gui, 1:Add, Text, xp yp wp hp+3 BackgroundTrans Center, Button

;********************************************************************************

Gui, 1:Add, ListBox, xm y+30 w300 r15 
Gui, 1:Add, Button, xp yp w100 r3 gTest, Button


Gui, 1:Add, Button, xm  w100 r3 gTest, Button
Gui, 1:Add, ListBox, xp yp w300 r15 +0x4000000 ;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=93402&p=413865&hilit=add+a+button+to+a+listview#p413858

Gui, 1:Show,

return
GuiClose:
GuiContextMenu:
*ESC::ExitApp

Test:
	ToolTip, In Test
	return

User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: Overlapping controls disables mouse input

Post by Capn Odin » 19 Sep 2021, 07:11

I solved the issue by combining the style WS_CLIPSIBLINGS suggested in the previous message with setting the Z-order of the control as was done in the thread I linked.
Please excuse my spelling I am dyslexic.
Post Reply

Return to “Ask for Help (v1)”