![]() |
#1 |
Junior Member
Join Date: Dec 2012
Posts: 11
|
NSD_OnClick is triggered on focus
Is it a known behavior? How can I filter only click events?
My code looks similar to this: code: The callback runs when I click on the button and when I focus on it. I need only click events. Thanks. |
![]() |
![]() |
![]() |
#2 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,453
|
Radio buttons are usually part of a group and you cannot focus a radio without selecting it. When you are notified you should just check which of the radios in the group is selected and take appropriate action.
In the most common case you don't even add a handler for a radio, you just check its state in the page leave callback function. Only catch the OnClick if you dynamically need to change something else on the page when the radio changes. Internally in Windows check-boxes and radio buttons are implemented as buttons and nsDialogs just catches the BN_CLICKED event for OnClick. IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#3 |
Junior Member
Join Date: Dec 2012
Posts: 11
|
> catches the BN_CLICKED event
Where can I see this code? I think the notification code is just not checked, and so BN_SETFOCUS triggers the callback as well. You can reproduce by compiling this example and pressing tab several times, you'll see a message box while you shouldn't: https://nsis.sourceforge.io/NsDialog...ton_selections |
![]() |
![]() |
![]() |
#4 | |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,453
|
Quote:
IntOp $PostCount $PostCount + 1 |
|
![]() |
![]() |
![]() |
#5 |
Junior Member
Join Date: Dec 2012
Posts: 11
|
Because I switch between "Next >" and "Install" button text depending on the selected radio button. Now there's a bug in which I switch the text while the user didn't actually select the ratio button. I can work around it by checking whether the button is actually selected, but it's still a bug.
I found the code you referenced, but still the bug exists and I showed how to reproduce it easily. Looks like the code you provided is not involved in calling the callback in the scenario when focus is changed, but I didn't debug enough to understand why it's called. |
![]() |
![]() |
![]() |
#6 | |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,453
|
Radio buttons sends BN_CLICKED when it gets focus, don't ask me why.
Quote:
PHP Code:
PHP Code:
IntOp $PostCount $PostCount + 1 |
|
![]() |
![]() |
![]() |
#7 |
Junior Member
Join Date: Dec 2012
Posts: 11
|
What the heck Microsoft, and BN_CLICKED's documentation has no mention of focus!
Thank you, BM_SETDONTCLICK fixes it nicely. |
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|