Disabled button behaving differently in windows Form - winforms

I have two button on form as:
Now when hover the portion common to both button the enabled button shows the mouse hover effect as:
I am not sure why this is done in windows form.
I have checked the same thing in WPF sample it works just fine, There it does not show any effect when we are on disabled button.
If we click on the portion which is common for both button the click for Enabled button is fired.
I want to know why controls have this behavior?

Try putting the disabled button in a panel or a group. Controls aren't really meant to overlap like that, so I expect that the event handler just passes the click through to the enabled button.

Related

Accessibility issue radio buttons

I'm using AngularJS and have a custom directive for radio buttons so they can be placed anywhere on the site. I'm doing some accessibility work as some of the radio buttons when using JAWS screen reader. The issue I'm having is this: When you tab to a certain radio button groups the radio button does show focus and the screen reader reads the radio button label. However in certain radio button groups the screen reader doesn't read "do not prompt user to "to change the selection press the up or down arrow" as it should. Other radio buttons on my site using this directive do not have this issue. In the instances where this issue occurs you cannot use the arrow keys to change the radio buttons as you can in the fully functioning radio button groups sharing the same directive. However, when you tab past these buggy radio button groups and then do a backwards tab (shift + tab) back the radio button group it functions as it should. It receives focus and the screen reader reads everything out as it should.

is there a way of making sure a command is called when the button is clicked no matter what happens after the initial click?

At the moment the command works fine if you click and release on the button without moving the mouse. My issue is that it won't work if you click on the button and move the mouse(even if the mouse remains over the button) before releasing.
You can set the ClickMode property of the button as "Press" to get your expected result. ClickMode="Press"
My issue is that it won't work if you click on the button and move the mouse(even if the mouse remains over the button) before releasing.
I think you can do this, in this way:
Use Mouse.MouseDownEvent to register a Mouse.MouseMoveEvent, so if the user moves his mouse, it will be fired your custom MouseMoveEvent.
In your custom MouseMoveEvent you enable a flag, because the user move his mouse.
You can use a custom Mouse.MouseLeaveEvent and check if the flag is disable, in this case you do whatever you want because the user doesn't have moved his mouse.

WinForm button click methods are being renewed. with button onclick_1

I just finished completing my winforms app. Suddenly when I was changing background color of gridview. When I started my app for final tests the buttons were not working. I checked their on click code and it was correct. Then I double clicked the button it created new button onClick_1 method. SO now all the buttons are doing it :( I dont' know what to do. Please help
Looks like your events are no longer coupled to your code.
Do this for each of your buttons:
Open your designer
Click on your button
Open your properties tab
In this menu, click on the events button
You'll find your "Click" event.
Click on the arrow and select the correct event.

Buttons keeping their focus class after losing focus

I have some buttons in a bottom toolbar of a gridpanel that control adding, and removing records from the row-editing grid.
The handlers are pretty simple: "new" button creates an instance of the model, appends to the grid and then opens a row-editor on the new row; "edit" button just opens the selected row's row-editor; "remove" destroys the record from the store and refreshes the grid view.
For some reason these buttons don't lose the focus class that gives them a border when they have the focus. Here is a picture:
In the picture both the "New" button and the "Remove" button have the focus class, when I press the "Edit" button it also keeps the focus classes even after doing a complete row-edit operation and closing the row-editor.
I did find that when I mousedown on one of these permanently "focused" buttons and then mouseup away from it and then click something else the focus class goes away.
I know that I could put a blur handler for all button components in my respective controllers but I would have thought that this functionality was built in so I am asking to see if there is something I missed somewhere in the docs.
The classes that it won't let go of are these:
x-focus x-btn-focus x-btn-default-toolbar-small-focus
This is with ExtJS 4.1.0 in FF10 on Windows 7. But I did notice similar behavior in ExtJS 4.02 and 4.07, just haven't needed to handle it until now.
I found out what it was:
At some point in the handler chain for each of these buttons the button gets disabled. When a button is disabled in ExtJS it prevents the blur event from firing.
It was necessary to disable the buttons so the solution to simply add button.blur() in the handler was the correct way to do go about it.

WinForms Accept Button Annoyance

I have a base panel class that has (among other things) three buttons. I use subclasses of this base class in two different config dialogues. Both dialogues have an OK button set as the accept button.
In one of the dialogues, if I click one of the buttons in the base class, focus immediately returns to the OK button, so pressing the enter key works as expected.
In the other dialogue, focus remains wth the button in the base class that was clicked if it is enabled, or moves to the next button if the clicked button is no longer enabled.
There is no code that handles the base class button click events in either of the derived classes.
Ideas anyone?
I'm not sure what's going on in your first dialog because it doesn't seem to be operating the way I would expect it to. The second dialog sounds more like the standard behavior.
In Windows Forms, the AcceptButton property only comes into play when pressing Enter doesn't otherwise cause any actions. In both of your examples, clicking on a button should move the focus to that button, and subsequently pressing Enter would cause another click on that button.
In any event, I think it's generally preferable to stick with the Windows user interface guidelines and not automatically change the input focus back to the OK button. If the user clicks on one of the other buttons, the focus should stay there until they move it.
i don't know what language you are using, but the button class should have a focus method that will highlite it for enter pressing. in the click method, or when you open the dialog you can call this method to make the button you want get the form's focus
c#
myButton.Focus();

Resources