Cannot get current text in an Editable ComboBox
Hey all,
I'm creating an editable combobox with a few pre-set options, designed to let a user type in a destination for a file or select from some convenient presets, but I've run into a few problems. I'm creating the combobox like this:
It seems to be that comboBox.GetText() should return the current state of the text in the box that's being edited, but unfortunately it doesn't seem to. Instead, i'm getting what was originally in that spot before any editing took place (I.E: It's impossible for me to find out what the current string of edited text in the combobox is).
In Addition to this, when I call comboBox.GetSelectedItem().GetTag() It gives me a BaseComponent object back, which doesn't contain any information - notably it doesn't contain the string tag that I originally put there, meaning that too is impossible to get out. I can work around this issue by pushing to information into the name field (which is correctly preserved), but being unable to get the current text in the editable text box of the combobox seems to make ComboBox.IsEditable useless.
I'm creating an editable combobox with a few pre-set options, designed to let a user type in a destination for a file or select from some convenient presets, but I've run into a few problems. I'm creating the combobox like this:
Code: Select all
<ComboBox VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="6, 0" Height="24"
IsEditable="True" IsSynchronizedWithCurrentItem="True" Name="fileLocationBox" SelectedIndex="0">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" />
</DataTemplate>
</ComboBox.ItemTemplate>
<ComboBoxItem Tag="MyDocuments">MyDocuments/PEVS</ComboBoxItem>
<ComboBoxItem Tag="Desktop">Desktop</ComboBoxItem>
<ComboBoxItem Tag="MyPictures">MyPictures/PEVS</ComboBoxItem>
<ComboBoxItem >Current Folder</ComboBoxItem>
</ComboBox>
In Addition to this, when I call comboBox.GetSelectedItem().GetTag() It gives me a BaseComponent object back, which doesn't contain any information - notably it doesn't contain the string tag that I originally put there, meaning that too is impossible to get out. I can work around this issue by pushing to information into the name field (which is correctly preserved), but being unable to get the current text in the editable text box of the combobox seems to make ComboBox.IsEditable useless.
-
sfernandez
Site Admin
- Posts: 3184
- Joined:
Re: Cannot get current text in an Editable ComboBox
You are right, our implementation does the opposite thing (set TextBox text from the selected item text only) as expected (update ComboBox.Text with anything typed in the editable TextBox)
We will fix it for the next release.
About the Tag property, which API are you using? Native C++ SDK or Unity C#?
If you have something like this:
In native c++ you can get the string stored in Tag as follows:
API 1.1
API 1.2
And in Unity:
API 1.1
API 1.2
We will fix it for the next release.
About the Tag property, which API are you using? Native C++ SDK or Unity C#?
If you have something like this:
Code: Select all
<ComboBox>
<ComboBoxItem Content="Item 1" Tag="Something 1"/>
<ComboBoxItem Content="Item 2" Tag="Something 2"/>
<ComboBoxItem Content="Item 3" Tag="Something 3"/>
</ComboBox>
API 1.1
Code: Select all
ComboBoxItem* cbi = NsStaticCast<ComboBoxItem*>(comboBox->GetSelectedItem());
NsString& tag = Boxing::Unbox<NsString>(NsStaticCast<Boxing::BoxedValue*>(cbi->GetTag()));
Code: Select all
ComboBoxItem* cbi = NsStaticCast<ComboBoxItem*>(comboBox->GetSelectedItem());
const NsString& tag = Boxing::Unbox<NsString>(cbi->GetTag());
API 1.1
Code: Select all
ComboBoxItem cbi = comboBox.GetSelectedItem().As<ComboBoxItem>();
string tag = cbi.GetTag().AsString();
Code: Select all
ComboBoxItem cbi = (ComboBoxItem)comboBox.SelectedItem;
string tag = (string)cbi.Tag;
Re: Cannot get current text in an Editable ComboBox
I tried to convert the Tag to String in C++ like you did in your code but I get an error that the argument of Noesis::Core::BaseComponent* can not be converted into Noesis::Core::Boxing::BoxedValue*
My code looks like this:
My code looks like this:
Code: Select all
Noesis::Gui::Image* cbi = NsStaticCast<Noesis::Gui::Image*>(mCurrentDragImage);
NsString& tag2 = Noesis::Core::Boxing::Unbox<NsString>(cbi->GetTag());
-
sfernandez
Site Admin
- Posts: 3184
- Joined:
Re: Cannot get current text in an Editable ComboBox
Sorry, it was my fault, the C++ code I posted is for 1.2 version too (I will edit the post to fix it).
For 1.1 version you have to cast to the expected argument type:
For 1.1 version you have to cast to the expected argument type:
Code: Select all
ComboBoxItem* cbi = NsStaticCast<ComboBoxItem*>(comboBox->GetSelectedItem());
NsString& tag = Boxing::Unbox<NsString>(NsStaticCast<Boxing::BoxedValue*>(cbi->GetTag()));
-
sfernandez
Site Admin
- Posts: 3184
- Joined:
Re: Cannot get current text in an Editable ComboBox
We fixed this for the next release 1.2.4, ComboBox.Text will be updated each time you write in the editable textbox
Who is online
Users browsing this forum: Ahrefs [Bot] and 10 guests