Jump to content
Sign in to follow this  
MrChiliCheese

GUICtrlCreateEdit and tabulator

Recommended Posts

MrChiliCheese

Hello!

How do i manage that my edit control receives the press of the tab-key actually as tabulator-sign?

Thanks!

Share this post


Link to post
Share on other sites
Melba23

yetrael,

As far as I know you cannot use the Tab key directly in an edit control - you need to use Ctrl-Tab to insert a @TAB character into the text. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
MrChiliCheese

Seems you like answering my question.

Well, some easy things are always quite hard with AutoIT, but I'll figure a nice way to get it working.

Thanks, melba!

Share this post


Link to post
Share on other sites
Melba23

yetrael,

This is a Windows limitation - not AutoIt - as Windows uses the TAB key to change the keyboard focus to the next control in the TABSTOP list. So I doubt you will find an easier workaround than you already have in Ctrl-TAB. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
MrChiliCheese

Don't doubt me! :-D

Func _GUICtrlEdit_InsertTab()
If Not $bHotKeyFunctionRunning Then
$bHotKeyFunctionRunning = True
$iCharIndex = _GUICtrlEdit_GetSel($hEdit)[0]
_GUICtrlEdit_InsertText($hEdit, Chr(9), $iCharIndex)
$bHotKeyFunctionRunning = False
EndIf
EndFunc ;==>_GUICtrlEdit_InsertTab

Ans that is for the While...WEnd loop of the GUI:

Dim $bHotkeySet = False
While 1
$cFocus = ControlGetHandle($mGUI, "", ControlGetFocus($mGUI))
If $cFocus = $hwndEdit And $bHotkeySet = False Then
$bHotkeySet = True
HotKeySet("{TAB}", "_GUICtrlEdit_InsertTab")
ElseIf $cFocus <> $hwndEdit And $bHotkeySet = True Then
$bHotkeySet = False
HotKeySet("{TAB}")
EndIf
WEnd

Can still be improved!

Edited by yetrael

Share this post


Link to post
Share on other sites
BrewManNH

You'd be better off using GUISetAccelerator than using HotKeySet. Although, typing CTRL-Tab is still just as easy.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Melba23

BrewManNH,

+ 1 :thumbsup:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
MrChiliCheese

You sure? I always thought GUISetAccelerator would create an event for a button etc. Of course, I could create a dummy control and use it within this one.

I'll will check which one is faster and more usable.

And yes, CTRL-TAB is still handy. But I'm used to just Tab...

Share this post


Link to post
Share on other sites
BrewManNH

BTW, your code doesn't run. This line "$iCharIndex = _GUICtrlEdit_GetSel($hEdit)[0]" is formatted incorrectly.

This might work better for what you're attempting.

#include <GUIConstantsEx.au3>
#include <guiedit.au3>
Local $iEditID
Example()

Func Example()
     GUICreate("Custom MsgBox", 225, 80)

     $iEditID = GUICtrlCreateEdit("", 10, 10, 210, 20)
     Local $aAccelKeys[1][2] = [["{Tab}", $iEditID]]
     GUISetAccelerators($aAccelKeys)

     GUISetState() ; Display the GUI.

     While 1
          Switch GUIGetMsg()
               Case $GUI_EVENT_CLOSE
                    MsgBox(4096, "You selected", "Close")
                    ExitLoop

               Case $iEditID
                    _GUICtrlEdit_InsertTab()
          EndSwitch
     WEnd
     GUIDelete() ; Delete the GUI.
EndFunc   ;==>Example

Func _GUICtrlEdit_InsertTab()
     Local $iIndex = _GUICtrlEdit_GetSel($iEditID)
     _GUICtrlEdit_InsertText($iEditID, Chr(9), $iIndex[0])
EndFunc   ;==>_GUICtrlEdit_InsertTab


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
MrChiliCheese

Thanks BrewManNH,

I like the solution with the GUISetAccelerators, updated my script.

And yes, if you use the AutoIt beta, you can do it like I did!

3.3.9.3 (8th April, 2012) (Beta)

AutoIt:

- Added #1191: Explicit size of arrays optional for explicit initialization.

- Added: Array access on expression: StringSplit("a,b", ",")[1]

Share this post


Link to post
Share on other sites
BrewManNH

But, it won't run on the non-beta version of AutoIt, and that should have been mentioned in the post that you were using it on the Beta. Someone coming across this wouldn't know that, and using it on the production version throws an error.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
MrChiliCheese

You're right. I'll keep this in mind for further posts!

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  

×