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 » Push button by keystroke (without ALT)
Push button by keystroke (without ALT) [message #29920] Tue, 30 November 2010 09:49 Go to previous message
zeiler is currently offline  zeiler
Messages: 2
Registered: November 2010
Junior Member
Hello,

I'm new to the forum (and the UPP-Framework). I really like both Smile Nice work, the people are friendly, the answers helpful. I already searched the forum for my problem but didn't find the exact problem I have. Now here's my problem: I need the ability to push a button or executing the corresponding button callback when a key is pressed (without the ALT key).

My current solution is to derive a class from Upp::Button calling it MyButton and adding a function to that class which returns the protected Button-variable accesskey. Then I overwrite the main Windows Key()-function and add call button.PseudoPush when the access key is pressed.

Well, maybe I'll better show you the code:
In the header file I have the following:
class MyButton : public Button {
public:
	dword GetAccessKey();
};

dword MyButton::GetAccessKey()
{
	return ToLower((wchar)accesskey);
}

In the main Windows class declaration I add the button:
MyButton button;

In the main Windows constructor:
button.SetLabel("E&xit");

And finally in the overwritten Key()-function of the main Window:
bool MyMainWindow::Key(dword key, int count)
{
	if ( button.GetAccessKey() == key )
	{
		button.PseudoPush();
		return true;
	}
	return TopWindow::Key(key, count);
}

Now here's my question:
Is there a better, cleaner, more elegant solution to this problem?

Best regards,
Julian
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to center the top most window?
Next Topic: printing RichEditWithToolBar rotated 90 degrees?
Goto Forum:
  


Current Time: Wed May 15 15:17:31 CEST 2024

Total time taken to generate the page: 0.01969 seconds