BUG: Inherited Button

M

Mick Doherty

Steps to reproduce:

Inherit from button.
Add button to project's form.
Run project.
Make button Default.
Press and Hold SpaceBar (so button is pressed)
Move Mouse.
Release SpaceBar.

The button now recieves the first MouseDown and MouseUp events even if the
cursor is not over the button.

Has anyone else seen this? I couldn't find it documented.
 
M

Mick Doherty

What's more:
Inherit from ButtonBase and the Button will not repaint after a click by
mouse. It stays Pushed until it loses focus.

"Mick Doherty"
 
M

Mick Doherty

For anyone who's interested, both bugs are related.
The actual Bug is the ButtonBase one which Button then Inherits.
Simple Solution is to Override the OnClick and OnDoubleClick events and add:

MyBase.OnClick(e)
MyBase.OnLostFocus(EventArgs.Empty)


"Mick Doherty"
 
C

Codemonkey

Nice one Mick. Cheers for sharing with the group. I wish more people done
this more often.

If you ever feel like solving the other 101 bugs in dotnet and Visual
Studio, feel free to share them too ;)

"Mick Doherty"
 
M

Mick Doherty

And I thought no one was listening.

Are there only 101? :)

I just thought I'd sort out the "No Icon in a FlatStyle.System Button" bug.
I thought it was going to be easy and to a certain extent it was, but I was
banging my head trying to figure out what I had done wrong to cause the
Paint errors I was seeing, and as it turns out it wasn't me, it was the
Tools I was using (does that make me a bad workman?).
I think I've finished it now, at least I can't think of any other things a
user might do to misuse a button.
Time to look over the code and see what improvements I can make.

Codemonkey said:
Nice one Mick. Cheers for sharing with the group. I wish more people done
this more often.

If you ever feel like solving the other 101 bugs in dotnet and Visual
Studio, feel free to share them too ;)

"Mick Doherty"
message news:[email protected]...
For anyone who's interested, both bugs are related.
The actual Bug is the ButtonBase one which Button then Inherits.
Simple Solution is to Override the OnClick and OnDoubleClick events and add:

MyBase.OnClick(e)
MyBase.OnLostFocus(EventArgs.Empty)


"Mick Doherty"
message news:[email protected]...
What's more:
Inherit from ButtonBase and the Button will not repaint after a click by
mouse. It stays Pushed until it loses focus.

"Mick Doherty"
<EXCHANGE#[email protected].[mdaudi100#ntlworld.com]>
wrote
in
message Steps to reproduce:

Inherit from button.
Add button to project's form.
Run project.
Make button Default.
Press and Hold SpaceBar (so button is pressed)
Move Mouse.
Release SpaceBar.

The button now recieves the first MouseDown and MouseUp events even
if
the
cursor is not over the button.

Has anyone else seen this? I couldn't find it documented.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top