How do I focus a Canvas programmatically?


Author
Message
Karl Hulme
Karl Hulme
Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)
Group: Forum Members
Posts: 6, Visits: 16
My problem is related to calling SetFocus from the constructor.
Calling SetFocus from the MouseDown event of the canvas works fine, and the FocusDecorator seems perfectly consistent now too.

I spent hours trying to figure this one out.  And then solved it within minutes of posting on this forum - d'oh!
Karl Hulme
Karl Hulme
Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)Forum Guru (50 reputation)
Group: Forum Members
Posts: 6, Visits: 16
Whenever I call NCanvas.Focus() it always returns false.

I've set NCanvas.AllowFocus to true, along with .AllowMouseCapture and .AllowDrop and .AllowTabStop.
I've also provided a FocusDecorator by specifying a color and stroke width. (This works occasionally but I'm not sure what's triggering when this does or doesn't appear)

I'm using the NCanvas.GotFocus and LostFocus events to determine if focus has been achieved.  My real interest is using the KeyDown event.

I find that I can tab into the canvas from the NTab parent, and then all the events fire as required.
But I cannot focus the canvas simply by clicking on it, or by calling NCanvas.Focus().

What am I missing?
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search