LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Path control update value while typing?

I have a path control and button on the screen. The button should only be enabled if the file in the path control exists, otherwise it should be grayed out. The user can type in a path or browse for the file, both are allowed.

 

The problem is that if the path is valid (so we enabled the button) and then the user edits the path, making it invalid then still can click on the button cause it seems that the button value change event fires earlier than the path control value change. This could cause a rare, race condition type event when the use actually can press the button without having a valid path.

 

I can solve by checking the path validity again at the button value change event, but I'm wondering if there is an easier way, like an update while typing type thing on string controls. Or a mechanism to fire the path value change earlier than the button value change.

 

thx.

0 Kudos
Message 1 of 6
(1,057 Views)

I think the simpliest solution is indeed checking the validity of the path during the "button pressed" event.

 

Another one could be to replace the path control by a string control. To use its "update while typing" option.

And adding a button control to replace the "browse" button included in the path control.

 

 

0 Kudos
Message 2 of 6
(1,022 Views)

Hi 1984,

 


@1984 wrote:

I can solve by checking the path validity again at the button value change event, but I'm wondering if there is an easier way, 


What's easier than using the CheckIfFileFolderExists function when handling the button event?

It's just one VI…

 


PinguX wrote:

Another one could be to replace the path control by a string control. To use its "update while typing" option.

And adding a button control to replace the "browse" button included in the path control.


You could place the string control OVER the path control and only leave the browse button visible:

  • so you can still use the browse feature and only need to copy the selected file path to your string control
  • you get the "update while typing" behaviour of the string
  • you need to think about handling possible "not a path"/"invalid path" values from the path control
  • you need to implement several event cases to handle all these user actions

So you need to decide which one is "easier": checking filepath validity on button press or building a nice(r) GUI with several event cases…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 6
(1,011 Views)

In theory you can use Key Down? Event and check here validity (with trivial RegExp, for example), this will be triggered on each entered char and you can discard invalid:

filepath.gif

This would be a little trickier if you wanted to handle cases where the user places the cursor in the middle of the string and edits it, but it should still be possible in theory. Alternatively, you could simply use a string over a path, as suggested.

0 Kudos
Message 4 of 6
(1,001 Views)

@GerdW wrote:

 


You could place the string control OVER the path control and only leave the browse button visible:

  • so you can still use the browse feature and only need to copy the selected file path to your string control
  • you get the "update while typing" behaviour of the string
  • you need to think about handling possible "not a path"/"invalid path" values from the path control
  • you need to implement several event cases to handle all these user actions

So you need to decide which one is "easier": checking filepath validity on button press or building a nice(r) GUI with several event cases…


You can also just add a "Browse for File"  button that calls the "File Dialog" vi and not have to worry about merging the two controls.

Message 5 of 6
(942 Views)

This seems to work.

If you want to do the same thing with multiple VIs, I suggest making this into an XControl.

0 Kudos
Message 6 of 6
(909 Views)