Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Focusable Canvas

 
 
Old 07-25-2006   #1 (permalink)
=?Utf-8?B?Sm9obiBEdW5u?=


 
 

Focusable Canvas

I'm having trouble with getting my Canvas to grab focus. In the constructor
of my view that derives from Canvas I'm setting

Focusable=true

but OnGotFocus never gets called. My app also has a treeview in it and it
doesn't show that it's lost focus when clicking on the viewer ( by changing
it's hilight color from dark to light gray ). I also tried the following

FrameworkElement::FocusableProperty->OverrideMetadata( Type::GetType(
"view_t" ), gcnew FrameworkPropertyMetadata( true ));

which I found mentioned somewhere - but it had no effect either. Which is
fine since I'm not sure what the above does anyways. The canvas does receive
mouse messages ( OnMouse* ) which I am calling the base class Canvas handers.
I've also removed all OnMouse* overrides which didn't fix the problem either.

If it's not obvious this is all being written in C++/CLI.

Thanks-

John

My System SpecsSystem Spec
Old 07-31-2006   #2 (permalink)
Marcus


 
 

Re: Focusable Canvas

Hi John,

Simply and dumb question?

Have you tried in your OnMouseDown() handler to call this.Focus()?

I have done soimething fairly similar and it works fine, a
previously non-focusable control can grab focus this way...

Also, you might need to change the KeyboadNavigation.TabNavigation
and KeyboardNavigation.DirectionalNavigation attached properties in
order to allow keyboard to pass focus to your canvas when cycling with
tab or navigating with arrows...

John Dunn wrote:
> I'm having trouble with getting my Canvas to grab focus. In the constructor
> of my view that derives from Canvas I'm setting
>
> Focusable=true
>
> but OnGotFocus never gets called. My app also has a treeview in it and it
> doesn't show that it's lost focus when clicking on the viewer ( by changing
> it's hilight color from dark to light gray ). I also tried the following
>
> FrameworkElement::FocusableProperty->OverrideMetadata( Type::GetType(
> "view_t" ), gcnew FrameworkPropertyMetadata( true ));
>
> which I found mentioned somewhere - but it had no effect either. Which is
> fine since I'm not sure what the above does anyways. The canvas does receive
> mouse messages ( OnMouse* ) which I am calling the base class Canvas handers.
> I've also removed all OnMouse* overrides which didn't fix the problem either.
>
> If it's not obvious this is all being written in C++/CLI.
>
> Thanks-
>
> John


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Canvas does not allow drawing Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46