Home » U++ Library support » U++ Widgets - General questions or Mixed problems » DropList bug when using convert, and a possible fix
DropList bug when using convert, and a possible fix [message #60261] |
Fri, 27 October 2023 16:06 |
zsolt
Messages: 702 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
An example:
using namespace Upp;
struct MyApp : TopWindow {
DropList dl;
MapConvert convert;
MyApp()
{
convert
.Add(1, "Alpha")
.Add(2, "Beta")
.Add(3, "Gamma")
.Add(4, "Delta")
;
dl.SetConvert(convert);
dl
.Add(1)
.Add(2)
.Add(3)
.Add(4)
;
Add(dl.HSizePos().TopPos(5, Ctrl::STDSIZE));
ActiveFocus(dl);
SetRect(0, 0, 200, 70);
}
};
GUI_APP_MAIN
{
MyApp().Run();
}
The problem is, that pressing A, B, G or D on keyboard it doesn't select any value.
But pressing 1, 2, 3 or 4 it does.
Fix:
@@ -157,15 +157,16 @@ int PopUpList::GetCursor() const
bool PopUpList::Key(int c)
{
int q = GetCursor();
q = q >= 0 ? q + 1 : 0;
c = ToUpperAscii(c);
for(int i = 0; i < GetCount(); i++) {
int ii = (q + i) % GetCount();
- if(ToUpperAscii(*StdFormat(items[ii]).ToWString()) == c) {
+ int current = convert ? *convert->Format(items[ii]).ToString().ToWString() : *StdFormat(items[ii]).ToWString();
+ if(ToUpperAscii(current) == c) {
SetCursor(ii);
return true;
}
}
return false;
}
|
|
|
Goto Forum:
Current Time: Sun May 11 04:23:39 CEST 2025
Total time taken to generate the page: 0.02660 seconds
|