Sign in to follow this  
Followers 0
Mikeman27294

Prevent tab brom selecting text

6 posts in this topic

#1 ·  Posted (edited)

Hello everyone.

I have been working with a rich editbox. I have indents working well, the only problem being that once I have indented, it selects the text. I know that if I set it not to sleep, then it wil not select the text, the problem then being that it just continues to insert indents. Here is the code for the indent function.

Func _Indent()
    _GUICtrlRichEdit_InsertText($Richedit, "    ")
    Sleep(500)
    Do
        _GUICtrlRichEdit_InsertText($Richedit, "    ")
        Sleep(100)
    Until Not _IsPressed(09)
EndFunc

I am calling this function using This code in a while loop in my main function.

Case _IsPressed("09")
    _Indent()

This is the code that I am using for my GUI and rich editbox.

GUICreate("", @DesktopWidth*0.75, @DesktopHeight*0.75, @DesktopWidth*0.125, @DesktopHeight*0.125, 0x010F0000)

And

$CodeDialog = _GUICtrlRichEdit_Create($hGUI, "", 2, 2, $DialogWidth, $DialogHeight, 0x0044)

Anybody know anything that can be done to prevent it from selecting the text inside the rich editbox?

Thanks.

EDIT

I just found the command _GUICtrlRichEdit_Deselect and I implemented that into my script more times than should be nessecary... but that hasnt worked.

_GUICtrlRichEdit_InsertText($CodeDialog, "  ")
Sleep(10)
_GUICtrlRichEdit_Deselect($CodeDialog)
Sleep(500)
_GUICtrlRichEdit_Deselect($CodeDialog)

See? more times than nessecary... but that hasnt helped at all.

Edited by Mikeman27294

Share this post


Link to post
Share on other sites



Anybody got any ideas?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Anybody got any ideas?

You are a bit impatient, especially since it's Sunday (for me anyway)

Why do you want to insert a variable number of tabs? It would be easier to insert only one for each key press. So

Func _Indent()
    _GUICtrlRichEdit_InsertText($Richedit, "    ")

    Do
        Sleep(50)
    Until Not _IsPressed(09)
EndFunc

As far as the highlighting problem goes I would need as small working example to show the issue, but if you don't want any of the text selected could you just have SetSel with the end the same as the start?

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Thanks. Yeah, I was a little impatient. It is basically going to be part of a larger application, but this part being similar to notepad. But thanks for that idea... I will take a look after I have done my assessment due tomorrow (I shouldnt have left it so late lol).

Share this post


Link to post
Share on other sites

No ideas?;

Share this post


Link to post
Share on other sites

Guess not. Anybody know how to edit the title? I'm sure I have seen it done before.

Share this post


Link to post
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
Sign in to follow this  
Followers 0