This is a migrated thread and some comments may be shown as answers.

RadTreeView steals Enter key from IsDefault button

1 Answer 94 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
PaulR
Top achievements
Rank 1
PaulR asked on 11 Nov 2016, 01:39 AM

Hey,

I've seen some other threads on this topic, so here's my example scenario. If you have a Window with an OK button with IsDefault=true, and you show the window in modal mode (dialog), the Enter key is supposed to be able to dismiss (close) the dialog. Unfortunately, if there's a RadTreeView in the window, which has keyboard focus, and the selection is on a node that does NOT have any children (so can't be expanded/collapsed anyway), the RadTreeView eats the Enter key and the window is not closed automatically. (Look at the ToggleExpandCollapseCommandCanExecute method, canExecute is set to true whether the RadTreeViewItem has Items or not).

 

I know, there's a super-easy workaround and that's to override OnPreviewKeyDown or OnKeyDown in the window code behind, which I'll do, but, the point of posting this thread is that this is not how Microsoft's TreeView works. They don't care about the Enter key probably precisely for this reason. Maybe provide a property to enable/disable this Enter key behavior would be nice.

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 15 Nov 2016, 03:38 PM
Hi PaulR,

We got your point. This is a valid feature request you can submit in our feedback portal which we will discuss internally and eventually approve it. However, please have in mind the following thoughts:

     - overriding some Key event is a perfectly valid way to customize our control in a way that is required for your application. Often, many features inside the control might use single shared key  (loadondemand, editing, expand collapsing) as well as features in outside control - like the default button of dialog window that you mention. Yes we can add property for such scenario, but every property needs tests, maintenance, runtime change behavior, etc. So often we will decide to support 90 percent of the component's use cases of a out of the box, leaving the rest 10 % possible to go with overriding methods, custom styles, commands, viewmodel tricks etc.
  
    - in this particular case even though an item has no children , Enter key might be important in cases when load on demand is enabled, the expander icon is shown and pressing Enter leads to firing LoadOnDemand event. This is just to prove the above statement that sometimes couple of features might use one action and making such changes (by introducing a property), should be made more precisely.

Regards,
Petar Mladenov
Telerik by Progress
Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
Tags
TreeView
Asked by
PaulR
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or