LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

select value inside numeric

Solved!
Go to solution

For convenience, I'd like the behavior of my numeric controls to auto select the entire value when I click the control.  So when it gets focus, the value should be selected.

 

I'm not seeing a way of doing this.  Any ideas?  The increment buttons on a numeric will select it, but these datatypes I have set to float.  So incrementing doesn't make much sense.  In my case, I have the user punching in values with the keyboard.  It would be nice to not have to first select the 0.000 already present before data entry.

 

Thoughts?

0 Kudos
Message 1 of 9
(4,901 Views)

I don't think you can do that with numerics, but you can with text with the ATTR_TEXT_SELECTION_START/LENGTH attributes. Simply set it when you get a FOCUS event.

0 Kudos
Message 2 of 9
(4,890 Views)

Yeah, that's what I was thinking.  Oh well.

0 Kudos
Message 3 of 9
(4,886 Views)

Just as a side note, if the user tabs among controls present value will be automatically selected. The same happens on a single control if he clicks on the control label instead of inside the input area.

 

Having said that, with several years of experience I know users are not willing to learn this simple trick and will always click inside the control complaining they must additionally double-click to select the value... Smiley Frustrated



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 9
(4,873 Views)

Maybe you could try and generate a shift-tab followed by a tab to emulate it when the user clicks on it (left clic event or got focus event). Use FakeKeyStroke() for that.

Message 5 of 9
(4,868 Views)

Unfortunately not: it seems there remains some click event in the queue that makes the selection disappear. If you process draw events between the two FakeKeystroke you see the text selected and then unselected.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 9
(4,864 Views)
Solution
Accepted by topic author ElectroLund

@gdargaud: with a little modification your idea can work!

You simply need to simulate a Home + Shift-End event to select text:

	if (event == EVENT_GOT_FOCUS) {
		FakeKeystroke (VAL_HOME_VKEY);
		FakeKeystroke (VAL_SHIFT_MODIFIER | VAL_END_VKEY);
	}

This is valid for both text and numeric controls. 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 7 of 9
(4,860 Views)

I love this user group!  Nice solution, guys.  Works very nicely.

0 Kudos
Message 8 of 9
(4,848 Views)

Yeah, well, don't forget to test it also for the keyboard users, as it's usually a bad idea to try and second-guess the users...   :womanmad:

0 Kudos
Message 9 of 9
(4,837 Views)