How to Kill focus of an MFC button control - button

I have an MFC button control and I am trying to handle the "OnPressed" event of it by starting a timer on click and making it go through my event in the OnTimer function. This all works fine but the focus remains on the button and if I click outside of the button area, the app carries out the OnPressed event. Any suggestions on how to kill the focus on the button when the mouse is pressed outside of the button area? My code for getting the focus and button ID.
void Dlg::OnTimer(...)
{
CWnd * pFocus = GetFocus();
int btnID = 0;
if (pFocus != NULL && pDialog->IsChild(pFocus))
btnID = pFocus->GetDlgCtrlID();
// Carry on my button pressed activity
Buttonpressed();
}
So basically I am getting the proper button press and I can carry out the desired action using the Buttonpressed() function given above. Now my problem is, once that button is pressed, it gets focus and the focus remains even after I leave the mouse and move out of the area of the button. Because of this behaviour, if I click outside of the button area, the application still thinks that I am in the mouse area and pressing the button. Is there a way I could remove focus after the mouse is moved out of the button area and then bring focus back in again when it is in the button area?
Looking forward to your suggestions.

Related

Difference between focus, focusleave,focusenter with extjs

Can anyone explain me what the difference between focus, focusleave and focusenter on button method with extjs, I'm lost because it seems to be the same when I add event listener. Thanks
kind regards
difference between focus, focusleave and focusenter on button method
with extjs
Method? I guess you mean the events right? Cos:
The focus method will focus your button when you call it.
As you can see on the picture the middle button has focus, you can change the focus on the webpage usually by using TAB key. ExtJS supports full control over your app using keyboard.
The focus, focusenter, focusleave events. If you are not sure what to use - just use "focus"
The focus event should be clear - it's simply fired when the button has focus.
The focusenter is fired when the component get's focus but as the docs states it's also fired in the whole component hirearchy. That means that if the button is in panel which is in view and you focus the button - the focusenter will be fired on the view, panel, button.
main -> panel -> button
Events
The focusleave is the same as focus enter. Fired when focus is lost on the component - again fired in the whole hirearchy. So if the focus went completly away form the page you would see focus leave on the button -> panel -> view

Let QTabWidget switch to corresponding page when mouse cursor hover on the tab

I want to show the corresponding page when mouse cursor hover on the tab of a QTabWidget.
For example, when the mouse cursor hover on tab ‘page2’ here , I hope the QTabWidget shows the corresponding page automatically instead of clicking. How to implement this feature?
You may try adding an event filter on the QTabWidget object's QTabBar in order to trap the mouse move event. In the filter handler, use QTabBar::tabAt( QPoint ) to find which tab is below the cursor. Set up a timer when the cursor first enters a given tab, reset time when cursor leaves it. When the timer fires, switch active tabs.
You may try using setTabToolTop function.
ui->tabWidgetHz->setTabToolTip(0,"tooltip for tab1.");
ui->tabWidgetHz->setTabToolTip(1,"tooltip for tab2.");
ui->tabWidgetHz->setTabToolTip(2,"tooltip for tab3");

Click on button (with Tablet) don"t work

I have problem with click button in tablet.Problem is when i press first time on button i get button:hover and that when i press again on this button it do the event.
(First touch making button hovered and Second make the event)
I need to do some kind double click to do the event or to disable button:hover(i don"t want this solution).
Or i need to check if this (first)click come from Tablet then i can to disable button:hover but only to Tablet users to Pc
Can any 1 know how to resolve this problem?

Flex tooltip disappears when button is Clicked

I have tooltips in flex but when a component is clicked the tooltip disappears and the user has to move mouse out of the control and then back into the control to display the tooltip.
Is there a way to prevent the tooltip from getting destroyed on mouse click.
I tried calling
e.stopImmediatePropagation();
e.preventDefault(); on mouse click event of button. also tried handling and preventing tooltipEnd and tooltipHide events but they are not fire when the button is clicked.
Thanks.
I have fixed the issue by adding a event handler to the mouseDown event and then calling preventDefault and stopImmediatePropagation there this prevents the tooltip from vanishing and the button is still clickable.

In flex, how to trigger mouseevent when the focus is on TextInput?

In flex, I am using the following:
mx:TextInput mouseOver="tester(event)"
It works fine. My pointer goes over the textInput and it calls the function. But when I click inside the textInput to enter some text( focus is on the textInput) and then move the mouse (not taking mouse pointer outside of the boundary of textinput), the mouseover event is not trigerred.
If I use click event, then even if I am entering text ( or the focus is on the textinput) and then click, it will call the function.
How can I call the tester function on mouseover when the focus is on textInput?
The mouseOver event fires when the mouse is moved over the control.
Maybe you want to try the mouseMove event which will fire every time the mouse moves?
Keep in mind that mouseEvents and focusEvents are not inherently related. I would expect the mouseOver event to fire when the mouse rolls over your textInput regardless of whether or not that textInput has the focus.

Resources