Hello,
I was wondering if there is a way to include "options" in a combo-box that includes "|" and "||" as part of the string. Any way to escape them or any know workaround?
Regards
ComboBox include strings with "|" and "||
-
- Posts: 58
- Joined: 18 Feb 2015, 15:06
Re: ComboBox include strings with "|" and "||
Use http://ahkscript.org/docs/commands/Gui.htm#Options "Delimiter: Specifies that the window should use a field separator other than pipe (|)"
Re: ComboBox include strings with "|" and "||
does the backtick ` not work as escape char? as in `| ?
-
- Posts: 58
- Joined: 18 Feb 2015, 15:06
Re: ComboBox include strings with "|" and "||
The problem using that option is that it just moves the same problem to another character. I want to allow the user to set any string to be used into the combobox, so they can end using the "new" Delimiter character at some point.Guest wrote:Use http://ahkscript.org/docs/commands/Gui.htm#Options "Delimiter: Specifies that the window should use a field separator other than pipe (|)"
-
- Posts: 33
- Joined: 09 Jan 2015, 13:19
Re: ComboBox include strings with "|" and "||
Hello.
Can't you use the following?
comboBoxList := RegExReplace(list, anySignSeperator, "|")
Can't you use the following?
comboBoxList := RegExReplace(list, anySignSeperator, "|")
-
- Posts: 58
- Joined: 18 Feb 2015, 15:06
Re: ComboBox include strings with "|" and "||
Sorry, I don't understand your point at all.AndreySibiryakov wrote:Hello.
Can't you use the following?
comboBoxList := RegExReplace(list, anySignSeperator, "|")
The problem is that the end user can include any string. So what I have to do is to escape the special characters the user could input, not the other way round.
-
- Posts: 33
- Joined: 09 Jan 2015, 13:19
Re: ComboBox include strings with "|" and "||
Ok, I understand it. But will the end user edit the code?
If not, you can use RegExReplace command to find and replace any character that user will use.
For example, "space" is used or "tab".
And the end user can enter this sign in a window from where a variable "anySignCharacter" can obtained.
If not, you can use RegExReplace command to find and replace any character that user will use.
For example, "space" is used or "tab".
And the end user can enter this sign in a window from where a variable "anySignCharacter" can obtained.
Re: ComboBox include strings with "|" and "||
You can use a character that the user is unlikely (or unable) to enter, such as an ASCII control character. If you're specifically targetting Unicode versions of AutoHotkey, you can use a non-character code point such as Chr(0xFFFF).
Alternatively, you can send ComboBox messages to the control instead of using the Gui commands.
Alternatively, you can send ComboBox messages to the control instead of using the Gui commands.
-
- Posts: 58
- Joined: 18 Feb 2015, 15:06
Re: ComboBox include strings with "|" and "||
Hello Lexikos. I like your idea of using an ASCII control character, but I'm failing implementing it. Here is how I did it:lexikos wrote:You can use a character that the user is unlikely (or unable) to enter, such as an ASCII control character. If you're specifically targetting Unicode versions of AutoHotkey, you can use a non-character code point such as Chr(0xFFFF).
Alternatively, you can send ComboBox messages to the control instead of using the Gui commands.
Code: Select all
Delim:=Chr(0xFFFF)
gui, mainGui:+Delimiter%Delim%
[.....]
Gui, Add, ComboBox , vTemplate w%templatewidth%, % functionthatjoinsteverything(Delim)
Re: ComboBox include strings with "|" and "||
You might want to use CB_AddItem().
-
- Posts: 58
- Joined: 18 Feb 2015, 15:06
Re: ComboBox include strings with "|" and "||
Hello Lexikos. I end using `a as a separator. It is working for now, but I'm facing a small problem: I'm not able to set a selected item. This is done using "||" normally. What I tried is to use the delimiter twice, but it does not work. Any idea why?
Code: Select all
delim=`a
list:= "hello" . delim . delim . "dude" . delim . "How are you"
-
- Posts: 58
- Joined: 18 Feb 2015, 15:06
Re: ComboBox include strings with "|" and "||
Hello Just me. I thought about using it, but as I have read it has some delay after each addition. It also makes things a bit, more complicated because currently the items are stored on an object, and I just call the join method of that object with the correct delimiter. Anyway, if I use the CB_Additem approach, how do you set a default selected item?just me wrote:You might want to use CB_AddItem().
Re: ComboBox include strings with "|" and "||
Where did you read it?danielo515 wrote:... ,but as I have read it has some delay after each addition.
Instead of joining them into a string you could add them directly.danielo515 wrote:... , and I just call the join method of that object with the correct delimiter.
CB_SelectItem()danielo515 wrote: ... ,how do you set a default selected item?
Re: ComboBox include strings with "|" and "||
CB_AddItem just sends a CB_ADDSTRING message. If that has a delay, then so must the GUI commands, because they do exactly the same thing.
Funny. Chr(0xFFFF) is not ASCII, but Unicode.danielo515 wrote:I like your idea of using an ASCII control character, but I'm failing implementing it.
There are a few possibilities:Everything is appearing in the same line.
- You've applied +Delimiter to the wrong GUI.
- Your function is using the wrong delimiter.
- You're using an ANSI version of AutoHotkey, where Chr(0xFFFF) returns "".
It works just fine for me, just as you wrote it.I end using `a as a separator. It is working for now, but I'm facing a small problem: I'm not able to set a selected item.
Code: Select all
delim=`a
list:= "hello" . delim . delim . "dude" . delim . "How are you"
Gui +Delimiter%delim%
Gui Add, ComboBox, , %list%
Gui Show
Who is online
Users browsing this forum: filipemb, Ineedhelplz, mapcarter, peter_ahk, Rohwedder and 307 guests