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
DropList bug [message #6464] Mon, 13 November 2006 13:14 Go to next message
zsolt is currently offline  zsolt
Messages: 698
Registered: December 2005
Location: Budapest, Hungary
Contributor
Testcase:
#include <CtrlLib/CtrlLib.h>

struct MyApp : TopWindow {
	DropList dl;

	MyApp()
	{
		dl.Add("Alpha");
		dl.Add("Beta");
		dl.Add("Gamma");
		Add(dl.HSizePos().TopPos(5, Ctrl::STDSIZE));
		SetRect(0, 0, 200, 70);
	}
};

GUI_APP_MAIN
{
	MyApp().Run();
}


The problem is, that pressing 'a' key, "Alpha" is not selected. Generally, you can never select the first row of the list, pressing its first lettel on keyboard.

Fix:
I commented out one line, but I'm not sure, if it doesn't break any other thing.
bool DropList::Key(dword k, int) {
	if(IsReadOnly()) return false;
	switch(k) {
	case K_ALT_DOWN:
		Push();
		break;
	case K_DOWN:
	case K_RIGHT:
		Change(1);
		break;
	case K_UP:
	case K_LEFT:
		Change(-1);
		break;
	default:
		if(k >= 32 && k < 256) {
			//list.SetCursor(key.Find(value));
			int c = list.GetCursor();
			bool b = list.Key(k, 1);
			if(list.GetCursor() != c) Select();
			return b;
		}
		return false;
	}
	return true;
}
Re: DropList bug [message #6465 is a reply to message #6464] Mon, 13 November 2006 14:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
This should be (more) correct, I hope:

	default:
		if(k >= 32 && k < 256) {
			bool b = list.Key(k, 1);
			if(list.IsCursor() && key[list.GetCursor()] != value)
				Select();
			return b;
		}
		return false;


Mirek
Re: DropList bug [message #6466 is a reply to message #6465] Mon, 13 November 2006 15:15 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 698
Registered: December 2005
Location: Budapest, Hungary
Contributor
Seems to be working, thanks!
Re: DropList bug [message #6655 is a reply to message #6466] Tue, 21 November 2006 22:02 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 698
Registered: December 2005
Location: Budapest, Hungary
Contributor
The modified 611-dev3 version is not working again. But changing back to your previous correction works well:
	default:
		if(k >= 32 && k < 256) {
			bool b = list.Key(k, 1);
			//if(list.GetCursor() >= 0 && list.GetCount() < key.GetCount() && key[list.GetCursor()] != value)
			if(list.IsCursor() && key[list.GetCursor()] != value)
				Select();
			return b;
		}
		return false;
Re: DropList bug [message #6656 is a reply to message #6655] Tue, 21 November 2006 22:06 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
zsolt wrote on Tue, 21 November 2006 16:02

The modified 611-dev3 version is not working again. But changing back to your previous correction works well:
	default:
		if(k >= 32 && k < 256) {
			bool b = list.Key(k, 1);
			//if(list.GetCursor() >= 0 && list.GetCount() < key.GetCount() && key[list.GetCursor()] != value)
			if(list.IsCursor() && key[list.GetCursor()] != value)
				Select();
			return b;
		}
		return false;


Why I am so stupid ?

if(list.GetCursor() >= 0 && list.GetCursor() < key.GetCount() && key[list.GetCursor()] != value)

Mirek
Re: DropList bug [message #6658 is a reply to message #6656] Tue, 21 November 2006 22:13 Go to previous message
zsolt is currently offline  zsolt
Messages: 698
Registered: December 2005
Location: Budapest, Hungary
Contributor
Quote:

if(list.GetCursor() >= 0 && list.GetCursor() < key.GetCount() && key[list.GetCursor()] != value)

Thanks, this is working well Smile
Previous Topic: How to set the ***initial*** focus to an option?
Next Topic: AlignDisplay bug (?)
Goto Forum:
  


Current Time: Sat May 04 18:55:33 CEST 2024

Total time taken to generate the page: 0.01808 seconds