Home » U++ Library support » U++ Widgets - General questions or Mixed problems » ColumnList - Set(Value key, Value val) - Working right?
ColumnList - Set(Value key, Value val) - Working right? [message #28190] |
Sat, 21 August 2010 16:55 |
jeremy_c
Messages: 175 Registered: August 2007 Location: Ohio, USA
|
Experienced Member |
|
|
I have the following code:
Value id = codelist.GetData();
codelist.Set(id, "Hello World!")
It does not change the selected item. Instead it seems to be changing the item at an index of "id".
This code works as expected:
int idx = codelist.Find(id);
codelist.Set(idx, ~d.value);
From Assist++ it seems that .Set(Value key, Value val) should set it based on key, thus the first example should have worked?
Jeremy
|
|
|
|
Re: ColumnList - Set(Value key, Value val) - Working right? [message #29163 is a reply to message #29161] |
Fri, 08 October 2010 11:16 |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
It's a very small bug. See the definition of the Set functions:
void Set(int ii, const Value& key, const Value& val, bool canselect = true);
void Set(int ii, const Value& key, const Value& val, const Display& display, bool canselect = true);
void Set(int ii, const Value& val, bool canselect = true);
void Set(int ii, const Value& val, const Display& display, bool canselect = true);
void Set(const Value& key, const Value& val, const Display& display, bool canselect);
void Set(const Value& key, const Value& val, bool canselect);
You are intending to call Set(Value, Value) but there is no candiate for that, the closest being Set(Value, Value, bool). As there is an implicit declared from Value to int the compiler is actually choosing Set(int, Value), which sets the value using an index.
The quick solution is to add the canselect parameter to your call:
Value id = codelist.GetData();
codelist.Set(id, "Hello World!", true);
but the function definition should also be changed to have a default value.
|
|
|
Goto Forum:
Current Time: Sat Jun 08 08:18:18 CEST 2024
Total time taken to generate the page: 0.01491 seconds
|