mike1950r Posted March 8, 2023 Share Posted March 8, 2023 Hello, i use richedit textedit, but i cannot use the TABkey while writing. It always selcts the whole text, when I hit the TABkey. Thanks for assistance. cheers mike Link to comment Share on other sites More sharing options...
Musashi Posted March 8, 2023 Share Posted March 8, 2023 Not sure, if there is a special style parameter for that. You could try CRTL+TAB instead of the TAB key SOLVE-SMART 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
mike1950r Posted March 8, 2023 Author Share Posted March 8, 2023 Musashi, thanks for your answer. What we need is that if we hit the tabkey the text moves 8 spaces to the right. Nothing special, just like in notepad texteditor. But from any unknown reason, this does not work in richedit window. Chees mike Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted March 8, 2023 Share Posted March 8, 2023 (edited) Hi @mike1950r, Like @Musashi already suggested, you have to use CTRL+TAB to perform a \t (tab) within a Edit control (like RichEdit). You can also catch tab-pressing-event by a HotKey and insert your 8 spaces into the RichEdit control, because the default is 4 spaces (1 tab) as far as I know. So if you really need these 8 spaces, adjust your default tab size or use TAB as a HotKey to insert exact 8 spaces. HotKeySet('{TAB}', '_InsertEightSpaces') Func _InsertEightSpaces() _GUICtrlRichEdit_AppendText($hRichEdit, _StringRepeat(' ', 8)) EndFunc Best regards Sven Edited March 8, 2023 by SOLVE-SMART Musashi 1 Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
Musashi Posted March 8, 2023 Share Posted March 8, 2023 (edited) A quick google search reveals that TAB does not work in conjunction with RichEdit controls as you would expect from an editor, e.g. see : richedit-tab-how-to-set-to-8-characters-width In SciTE you can configure the length (indentation depth) that is triggered by TAB. However, this apparently has no effect on Richedit controls. @SOLVE-SMART 's approach works within the RichEdit control, but changes the default behavior of TAB between controls. Example : Comment the line with HotKeySet in and out to see the difference : #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> #include <String.au3> ;~ HotKeySet('{TAB}', '_InsertEightSpaces') ; <==== comment in and out Global $hRichEdit Example() Func Example() Local $hGui, $iMsg Local $idBtnHelp Local $idBtnFinish $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 420, 550, -1, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $idBtnHelp = GUICtrlCreateButton("Help", 10, 400, 150, 35) $idBtnFinish = GUICtrlCreateButton("Finish", 200, 400, 150, 35) GUISetState(@SW_SHOW) While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes Exit EndSelect WEnd EndFunc ;==>Example Func _InsertEightSpaces() _GUICtrlRichEdit_AppendText($hRichEdit, _StringRepeat(' ', 8)) EndFunc . Edited March 8, 2023 by Musashi SOLVE-SMART 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
mike1950r Posted March 9, 2023 Author Share Posted March 9, 2023 Thanks Solve Smart and Musashi, I understand now, that I have to capture the TAB and change to another command. I could also hotkey TAB and send CTRL + TAB in the function, right? Cheers mike Link to comment Share on other sites More sharing options...
Solution SOLVE-SMART Posted March 9, 2023 Solution Share Posted March 9, 2023 (edited) 36 minutes ago, mike1950r said: I could also hotkey TAB and send CTRL + TAB in the function, right? Yes you can. For example like this: HotKeySet('{TAB}', '_SendCtrlTabToRichEdit') Func _SendCtrlTabToRichEdit() _GUICtrlRichEdit_Deselect($hRichEdit) ; This is only to give the RichEdit control the focus. Send('^{TAB}') EndFunc This is even better than "append 8 spaces" like I suggested before 👍 . 💡 The complete example (previously by @Musashi) with the small adjustments: Spoiler #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> #include <String.au3> HotKeySet('{TAB}', '_SendCtrlTabToRichEdit') Global $hRichEdit Example() Func Example() Local $hGui, $iMsg Local $idBtnHelp Local $idBtnFinish $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 420, 550, -1, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $idBtnHelp = GUICtrlCreateButton("Help", 10, 400, 150, 35) $idBtnFinish = GUICtrlCreateButton("Finish", 200, 400, 150, 35) GUISetState(@SW_SHOW) While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes Exit EndSelect WEnd EndFunc ;==>Example Func _SendCtrlTabToRichEdit() _GUICtrlRichEdit_Deselect($hRichEdit) Send('^{TAB}') EndFunc But as @Musashi mentioned, if you want to jump between other controls (buttons, etc.) with TAB, you can not. Best regards Sven Edited March 9, 2023 by SOLVE-SMART Musashi 1 Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
mike1950r Posted March 9, 2023 Author Share Posted March 9, 2023 OK, great, I will do this. When I'm in the editcontrol I do not jump to other controls. Thanks lot Cheers mike Link to comment Share on other sites More sharing options...
jugador Posted March 9, 2023 Share Posted March 9, 2023 think it's working by mixing @Musashi hint CRTL+TAB & GUICtrlCreateDummy expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> #include <String.au3> __Example() Func __Example() Local $iMsg Local $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 420, 550, -1, -1) Local $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) Local $idBtnHelp = GUICtrlCreateButton("Help", 10, 400, 150, 35) Local $idBtnFinish = GUICtrlCreateButton("Finish", 200, 400, 150, 35) Local $id_Dummy = GUICtrlCreateDummy() Local $aAccelKeys[1][2] = [["{TAB}", $id_Dummy]] GUISetAccelerators($aAccelKeys) GUISetState(@SW_SHOW) While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes GUIDelete($hGui) Exit Case $iMsg = $id_Dummy _InsertEightSpaces() EndSelect WEnd EndFunc Func _InsertEightSpaces() Send('^{TAB}') EndFunc mike1950r 1 Link to comment Share on other sites More sharing options...
mike1950r Posted March 9, 2023 Author Share Posted March 9, 2023 Hi thanks, both solutions work fine, also the AccelKeys. Cheers mike Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now