Jump to content

Disable mouse click over edit control


mocro
 Share

Recommended Posts

Hello,

Is it possible to disable mouse clicking over an Edit control? If I use the Style $ES_READONLY it will still accept mouse clicks which can cause havok when trying to append text.

I tried setting the state of it to $GUI_DISABLE but that will also disable scroll bars.

Any help would be greatly appreciated.

Thanks,

Link to comment
Share on other sites

Yes I am using guictrlsetdata to append data to the control as opposed to overwriting the text. eg.

GUICtrlSetData($edit1, "data ", 1)

I was refering to the mouse click specifically, not the movement over the control. If you put the above code in a loop it will add.

data data data data

...etc to the edit. However if I click on the control while its looping, I may get

ddata ata data dadata ta

... and so forth depending where I click in the control.

Basically what I want to know is there a way I can append data to the end of the previously set data so that it won't be affected by mouse clicks?

Edited by mocro
Link to comment
Share on other sites

I would expect GUICtrlSetData() to fulfil your desired functionality by default. It doesn't make sense for the function to insert text at the cursor when you are instructing it to append -- perhaps this is an AutoIt bug.

What does everyone else think?

Link to comment
Share on other sites

Yes I am using guictrlsetdata to append data to the control as opposed to overwriting the text.  eg.

GUICtrlSetData($edit1, "data ", 1)

I was refering to the mouse click specifically, not the movement over the control.  If you put the above code in a loop it will add.

data data data data

...etc to the edit.  However if I click on the control while its looping, I may get

ddata ata data dadata ta

... and so forth depending where I click in the control.

Basically what I want to know is there a way I can append data to the end of the previously set data so that it won't be affected by mouse clicks?

<{POST_SNAPBACK}>

It sounds like the cursor position is being set when you click the Edit box, try keeping your string values in a varable and just use Edit box for display.
Link to comment
Share on other sites

It sounds like the cursor position is being set when you click the Edit box, try keeping your string values in a varable and just use Edit box  for display.

<{POST_SNAPBACK}>

And if that doesn't work, or you require more help, might be a good idea to post your code, would be easier to help you.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Thanks for the response. Here is the code I was tinkering with.

#include <GUIConstants.au3>
#Include <GuiEdit.au3>

GUICreate("My GUI")
$myedit=GUICtrlCreateEdit("", 10, 10, 380, 380, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_READONLY)
GUISetState()

While 1

    GUICtrlSetData ($myedit, "data ", 1)

    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop

WEnd

I can use a variable to hold the value however I was thinking that I would have to overwrite the edit control everytime I want to append new data. Its only a few extra lines of code and probably the only way. Unless there is a GUI constant I'm not aware of or I'm not using the advanced option in guictrlsetdata properly.

Link to comment
Share on other sites

I'm not aware of any special GUI constant and you appear to be using the GuiCtrlSetData() function properly. I hope that this thread receives the attention of a developer because this behaviour definitely sounds buggy.

Link to comment
Share on other sites

Not buggy:

GUICtrlSetData ( controlID, data [, default])

default - for Edit, Input : if defined and not "" the "data" string is inserted not overriding the previous value at the cursor point.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Ugh, how embarrassing. ;) I could have sworn that the flag indicates an append. When did I forget how to read? :P

Your options are to keep the entire output in a separate variable and overwrite the entire contents of the Edit control each time, or to force the cursor to the end of the current data immediately before inserting the new data (it can be done with _GUICtrlEditSetSel() but there's probably a more intuitive way).

Link to comment
Share on other sites

#include <GUIConstants.au3>
#Include <GuiEdit.au3>
#include <Misc.au3>

$GUI = GUICreate("My GUI", 500, 390)
$myedit = GUICtrlCreateEdit("", 10, 10, 380, 380, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_READONLY)

$Button = GUICtrlCreateButton("Exit", 400, 20, 90, 25)
GUISetState()
_NoClick()

While 1
    
    GUICtrlSetData($myedit, "data ", 1)
    
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button
            ExitLoop
    EndSelect
    _NoClick()
    
WEnd
_MouseTrap ()

Func _NoClick()
    Local $coords = WinGetPos($GUI)
    _MouseTrap ($coords[0] + 390, $coords[1], $coords[0] + $coords[2], $coords[1] + $coords[3])
EndFunc  ;==>_NoClick

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

if the data is highlighted it automatically overwrites it.

<{POST_SNAPBACK}>

Yes, but my theory was that you could 'set a selection that starts at the very end and ends at the very end', thereby simply moving the cursor to the very end without a resultant selection.
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...