Connecting Tech Pros Worldwide Help | Site Map

TreeView: How to capture Enter?

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 13th, 2005, 06:05 AM
(Pete Cresswell)
Guest
 
Posts: n/a
Default TreeView: How to capture Enter?

I've got KeyDown coding and it fires when other keys are pressed, but when Enter
is pressed, nothing.

I'd like to support the (standard?) Windows behavior of executing DblClick
processing when an item is selected and the user presses Enter

I got focus to stop moving to the next control via Tools|Options|Keyboard|Move
after enter....but now it just sits there and neither KeyDown nor KeyPress seems
to catch it.

Is this the end of the road?
--
PeteCresswell

  #2  
Old November 13th, 2005, 06:06 AM
David Schofield
Guest
 
Posts: n/a
Default Re: TreeView: How to capture Enter?

On Sat, 08 Jan 2005 20:10:17 GMT, "(Pete Cresswell)" <x@y.z> wrote:
[color=blue]
>I've got KeyDown coding and it fires when other keys are pressed, but when Enter
>is pressed, nothing.
>
>I'd like to support the (standard?) Windows behavior of executing DblClick
>processing when an item is selected and the user presses Enter
>
>I got focus to stop moving to the next control via Tools|Options|Keyboard|Move
>after enter....but now it just sits there and neither KeyDown nor KeyPress seems
>to catch it.
>
>Is this the end of the road?
>--
>PeteCresswell[/color]

Hi
The KeyDown and KeyUp events don't occur when you press the ENTER key
if the form has a command button for which the Default property is set
to Yes.

So maybe if you make sure it hasn't they will. You will have to to
trap and act on the enter key for command buttons yourself.
HTH
David

  #3  
Old November 13th, 2005, 06:06 AM
(Pete Cresswell)
Guest
 
Posts: n/a
Default Re: TreeView: How to capture Enter?

Per David Schofield:[color=blue]
>Hi
>The KeyDown and KeyUp events don't occur when you press the ENTER key
>if the form has a command button for which the Default property is set
>to Yes.
>
>So maybe if you make sure it hasn't they will. You will have to to
>trap and act on the enter key for command buttons yourself.
>HTH[/color]

No Command buttons w/.Default=True - and I tested that by putting a regular
ListBox on the same form. The regular ListBox's KeyDown event fires when
Return/Enter are pressed (KeyCode=13).

It's starting to sound like the TreeView's behaviour is somewhat different.
--
PeteCresswell
  #4  
Old November 13th, 2005, 06:08 AM
David Schofield
Guest
 
Posts: n/a
Default Re: TreeView: How to capture Enter?

On Sun, 09 Jan 2005 22:21:21 GMT, "(Pete Cresswell)" <x@y.z> wrote:
[color=blue]
>Per David Schofield:[color=green]
>>Hi
>>The KeyDown and KeyUp events don't occur when you press the ENTER key
>>if the form has a command button for which the Default property is set
>>to Yes.
>>
>>So maybe if you make sure it hasn't they will. You will have to to
>>trap and act on the enter key for command buttons yourself.
>>HTH[/color]
>
>No Command buttons w/.Default=True - and I tested that by putting a regular
>ListBox on the same form. The regular ListBox's KeyDown event fires when
>Return/Enter are pressed (KeyCode=13).
>
>It's starting to sound like the TreeView's behaviour is somewhat different.
>--
>PeteCresswell[/color]
Hi
Um ...
You can set the form.KeyPreview = true and catch ENTER with KeyDown at
the form level, check that the treeview is active and in a suitable
state (use the treeview events to set up this) and then call your
doubleclick event. But the ENTER will still be passed to the treeview
control as KeyDown doesn't have a cancel argument.

Straightforward subclassing the treeview doesn't catch Enter, but if
you are up for heavy coding see
How To Prevent the ENTER Key From Firing in TreeView Control
http://support.microsoft.com/default...b;en-us;216664

This is written for VB.

It is a bold developer who deploys any Access app with treeview in it,
let alone one with subclassing!

David


HTH
David

  #5  
Old November 13th, 2005, 06:08 AM
(Pete Cresswell)
Guest
 
Posts: n/a
Default Re: TreeView: How to capture Enter?

Per David Schofield:[color=blue]
>It is a bold developer who deploys any Access app with treeview in it,
>let alone one with subclassing![/color]

I've got a couple out there with no reported problems.

("Reported" being the operative word....)


Anything special I should be on the lookout for?
--
PeteCresswell
  #6  
Old November 13th, 2005, 06:08 AM
(Pete Cresswell)
Guest
 
Posts: n/a
Default Re: TreeView: How to capture Enter?

Per David Schofield:[color=blue]
>ou can set the form.KeyPreview = true and catch ENTER with KeyDown at
>the form level, check that the treeview is active and in a suitable
>state (use the treeview events to set up this) and then call your
>doubleclick event. But the ENTER will still be passed to the treeview
>control as KeyDown doesn't have a cancel argument.[/color]

Still no-go.

I checked it with ?frmWhatever.Keypreview in the immediate window....and,
indeed, it still fires KeyDown and KeyPress for the space bar and other
keys...but not Enter.

I think I see why, though. The list is already using Enter to toggle nodes'
..Expanded. Hit Enter on a collapsed node and it expands...do the same thing
on an expanded node and it collapses.

I guess that about wraps it.... I guess I'll just trap SpaceBar and tell the
users to learn to love it.
--
PeteCresswell
  #7  
Old November 13th, 2005, 06:09 AM
David Schofield
Guest
 
Posts: n/a
Default Re: TreeView: How to capture Enter?

On Tue, 11 Jan 2005 00:44:22 GMT, "(Pete Cresswell)" <x@y.z> wrote:
[color=blue]
>Per David Schofield:[color=green]
>>It is a bold developer who deploys any Access app with treeview in it,
>>let alone one with subclassing![/color]
>
>I've got a couple out there with no reported problems.
>
>("Reported" being the operative word....)
>
>
>Anything special I should be on the lookout for?
>--
>PeteCresswell[/color]
Hi
Problems with common controls arise mainly in MDE/run time systems
when older or newer versions of the DLL are on the user's PC
David

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.