Jump to content

GUIOnEventMode doesn't seem to disable events


Recommended Posts

While recently working on a project, I ran into this issue.

Can anyone confirm this?

 

Local $ID_GUI = GUICreate('GUIOnEventMode Test', 400, 400)
Local $ID_Open = GUICtrlCreateButton('Open', 290, 350, 80, 20)
GUICtrlSetOnEvent($ID_Open, '_GUI_CtrlMgr')
GUISetOnEvent(-3, '_GUI_CtrlMgr')
GUISetState(@SW_SHOW, $ID_GUI)
Opt('GUIOnEventMode', 1)
Local $n = 0
;
While 1
    Sleep(1000)
WEnd
;
Func _GUI_CtrlMgr()
    ;
    Opt('GUIOnEventMode', 0); disable events
    ;
    Switch @GUI_CtrlId
        Case $ID_Open

            ; Click GUI button 5 to 10 times while FileOpenDialog is visible and then release.
            ; Cancel the FileOpenDialog's and Watch the ToolTip.

            Local $sFile = FileOpenDialog('Select File', '', 'Text Files (*.txt)')
            $n += 1
            ToolTip('Number of Events: ' & $n, 0, 0)
        Case -3
            ToolTip('')
            Exit
        Case Else
    EndSwitch
    ;
    Opt('GUIOnEventMode', 1); enable events
    ;
EndFunc

Edit:

I commented out the Opt('GUIOnEventMode', 1) at the end of the function, and it Will Disable Events.

So, it must be something in the core code of AutoIt holding the events in memory, even though events are disabled.

I even tried it going back to v3.3.6.0 -- same thing.

 

Edited by ripdad

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

I found a solution.

Just disable it from the source, then re-enable after the code runs:

GUICtrlSetOnEvent($ID_Open, ''); disable event

; working code goes here

GUICtrlSetOnEvent($ID_Open, '_GUI_CtrlMgr'); enable event

 

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

By the way that GUICtrlSetOnEvent behaves, I believe the wording should be renamed from:

enable to start and disable to pause

Otherwise, one would have the wrong impression about the behavior of the function.

Just my opinion...

 

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

So, there has been an issue with events between AutoIt versions starting after v3.3.8.1

GUICtrlSetOnEvent($ID_Open, '') behaves the same way that Opt('GUIOnEventMode', 0) does.

Tested versions: AutoIt v3.3.10.0 through AutoIt v3.3.15.0

Which leaves me with the 3rd option:

GUICtrlSetState($ID_Open, $GUI_DISABLE)

; working code goes here

GUICtrlSetState($ID_Open, $GUI_ENABLE)

So far, that seems to be working out great, since the button itself is disabled.

 

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

  • Moderators

ripdad,

Sorry, only just noticed this thread. This problem should be fixed in the next release.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...