Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 is currently offline  zsolt
Messages: 697
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;
 }
Previous Topic: Drag and drop log
Next Topic: [BUG] File drag & drop does not work correctly if the path has a plus (+) sign in it.
Goto Forum:
  


Current Time: Mon Apr 29 10:21:34 CEST 2024

Total time taken to generate the page: 0.02083 seconds