GetLabel vs GetLabelText - Mnemonics

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Wanderer82
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 670
Joined: Tue Jul 26, 2016 2:00 pm

GetLabel vs GetLabelText - Mnemonics

Post by Wanderer82 »

These are two functions to get the text of a label in a wxStaticText. For "GetLabel" it says, that it can contain "mnemonics". I don't quite understand what that is and if it is ussually better to use GetLabelText?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: GetLabel vs GetLabelText - Mnemonics

Post by doublemax »

Example from the "minimal" sample:

Code: Select all

helpMenu->Append(Minimal_About, "&About\tF1", "Show about dialog");
The "&" in "&About" indicates that the next character afterwards (the "A") is a keyboard shortcut. If you press "Alt", that letter will be displayed underlined (at least under Windows). That's called an "mnemonic".
Use the source, Luke!
Wanderer82
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 670
Joined: Tue Jul 26, 2016 2:00 pm

Re: GetLabel vs GetLabelText - Mnemonics

Post by Wanderer82 »

Okay, so does that mean that GetLabel() will also copy these & to the string while GetLabelText() won't? So if I have a StaticText saying for examle "Hell&Earth" the GetLabelText() will omit the & and just copy "HellEarth" to a string? If that is the case, I should know which characters are used for mnemonics. Because if I want to use " or ; or other punctuation I risk that they will be omitted. So, actually I could say, I should just use GetLabel() anyways to be sure that all the punctuation gets copied to a string which is what I want.

Oh and by the way: I've also used GetValue() for ComboBoxes. I've just realized that. So what is the different between GetValue() and GetLabel()?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: GetLabel vs GetLabelText - Mnemonics

Post by doublemax »

The mnemonics are not added automatically, they will only be there if you put them there. So mostly you don't have to care about it.
So what is the different between GetValue() and GetLabel()?
GetValue is for editable texts, GetLabel for "static" texts (this also includes e.g. the label of a wxButton). Sometimes even the "wrong" one works, but that's not guaranteed.
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: GetLabel vs GetLabelText - Mnemonics

Post by ONEEYEMAN »

Hi,
To answer another question - I believe the mnemonic indicator is only '&' character, and you can't redefine it. It is system wise.

I may be wrong, though...

Thank you.
Post Reply