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 » Simulate a button click
Simulate a button click [message #37454] Sun, 07 October 2012 20:18 Go to next message
Mircode is currently offline  Mircode
Messages: 17
Registered: September 2012
Promising Member
Hi there!

My application shows a keyboard made of pusher-buttons. If the user clicks a button with the mouse, the keystroke gets simulated. On the other hand, if the user physically presses a key on his keyboard, the pusher has to look pushed as long as the user holds the key.

How can I do that?

PseudoPush almost does the trick, except it releases immediately. I dont know if the KeyPush() method would help, but its protected.

Ah, and I dont want to assign a hotkey to the pusher or something like that, I want to be able to make the button look pushed from anywhere in my code.

Thanks for help in advance!

Greetings,
Mirko
Re: Simulate a button click [message #37487 is a reply to message #37454] Wed, 10 October 2012 22:13 Go to previous messageGo to next message
Mircode is currently offline  Mircode
Messages: 17
Registered: September 2012
Promising Member
Inspired by this http://www.ultimatepp.org/forum/index.php?t=msg&th=6949& amp;start=0& I found a way:

The PseudoPush method is defined in Button.cpp and is actually very simple.

void Pusher::PseudoPush() {
	if(IsReadOnly() || !IsEnabled()) return;
	KeyPush();
	Sync();
	Sleep(50);
	FinishPush();
}


Now I created my own class, which offers the PseudoDown and the PseudoUp method.

class MyButton:public Button{
public:
    MyButton() {}
    ~MyButton() {}

	void PseudoDown(){
		if(IsReadOnly() || !IsEnabled()) return;
		KeyPush();
		Sync();
	}
	void PseudoUp(){
		FinishPush();
	}    
};


Works fine Smile
Re: Simulate a button click [message #37492 is a reply to message #37487] Thu, 11 October 2012 01:34 Go to previous message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Cool, thanks!
Previous Topic: QTF tooltip on tray icon.
Next Topic: Change window style
Goto Forum:
  


Current Time: Sun Sep 26 23:51:30 CEST 2021

Total time taken to generate the page: 0.01046 seconds