Select/highlight text when selecting the property

Editors for WPF Forum

Posted 6 years ago by Antoine Picard
Version: 18.1.0672
Avatar

Hi !

I was wondering if it's possible to select the content of a property when I click on it ? I think something like this post ( https://www.actiprosoftware.com/community/thread/6205/select-all-on-gotfocus-int32-double-editbox#22718 ) but as it's pretty old (7 years) do you have any idea how it would be possible ?

I tried something with the OnItemSelecting event but I didn't find anything to "highlight" the value. I would like the same selection as the tab behavior.

Comments (5)

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Antoine,

I'm not sure that's done easily because the property value editor can be anything.  In some cases it might be a TextBox, in others an Editors edit box, or something completely different.  It's up to the individual controls used in the property value editor template to determine how they react to mouse clicks.

You might be able to look at some PreviewMouseLeftButtonDown events or something like that on to try and catch a double-click before a child control ever gets them,  Then react based on the hierarchy of what was clicked appropriate.


Actipro Software Support

Posted 6 years ago by Antoine Picard
Avatar

Hi !

So if I understand well, there's no easy way.

With the OnPreviewMouseLeftButtonDown event, I have nothing more than what I have with ItemSelecting event. Moreover, it will be triggered by any click, even if it's not on an property, what's better with this event ?

I don't care about any double click, I just need a normal click to trigger the selection of the whole text (even if it's a string, bool, path...)

When you say "react based on the hierarchy of what was clicked appropriate", what do you mean ? I don't really understand this.

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Correct, using the preview mouse down event isn't any better really than using the ItemSelecting event.  In fact it's tricker because it could fire for any visual in the UI hierarchy so that means you'd have to walk up the visual tree to even determine which property row contains the UI element that was clicked, if any.  


Actipro Software Support

Posted 6 years ago by Antoine Picard
Avatar

Okay, so it's not really possible to do what I want ? Too tricky ?

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Antoine,

You might be able to support click-to-select-all functionality with some ideas like what's in here (i.e. Donnelle's answer):

https://stackoverflow.com/questions/660554/how-to-automatically-select-all-text-on-focus-in-wpf-textbox

Note that our product will try and select all text and focus the textbox when double-clicking on the related name column.  That makes it easy to edit the entire property value without any other tricks.  It can only do that for properties that use TextBoxes in their value property editors, but works very well for those.


Actipro Software Support

The latest build of this product (v24.1.3) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.