03-11-2020 07:27 AM
I am trying to trigger an event based on a user clicking the browse button (path on the front panel), i'm new to event structure and can't figure out how to do this. Does anyone have some old example code that they could share?
03-11-2020 07:39 AM
What are yo trying to do? The way I can think of to find the browse button would be to use the position info. Like this:
You know how big the control is so you would have to figure out where the browse button is inside of that coordinate world.
03-11-2020 07:40 AM
If you right click on the event structure, add event case, you can select your path control from the list and set the event to 'Value Change'.
This will trigger the event when the user changes the value of the path, either by typing or using the system file dialog which appears when you press the browse button.
If you need to specifically register a click on the browse button rather than just a value change this won't suffice, but I can't see a reason why you would want that. If that is the case I suggest you share more about what you are trying to achieve because I suspect that there is a better way of doing it.
03-11-2020 09:11 AM - edited 03-11-2020 09:15 AM
Check for a Mouse Down? filter event on the path control. If the Coords of the click is outside of the control itself, the button was clicked.
This example checks for the button on the right of the path control.
03-11-2020 09:11 AM
@aeastet wrote:
What are yo trying to do? The way I can think of to find the browse button would be to use the position info. Like this:
You know how big the control is so you would have to figure out where the browse button is inside of that coordinate world.
I used to make placeholder cases exactly like what you have there, with the dialog box - until one day I accidentally made a state machine whose state kept calling itself and I couldn't abort the VI because the message box kept getting in the way. Now I use the beep.vi so I can hear that it went through the loop. It's a lot easier to stop a runaway train that way. 😉
03-11-2020 09:13 AM
Not if you are programming with sound canceling headphones on. 😁
03-11-2020 09:15 AM
I can't really see a use for launching something off the clicking of the browse button. It should do just one thing: open the file dialog box. I think the OP meant to take some action after something has been selected. You can always send the results of the folder/file selection to the something that you want to open. It's pretty easy; it's been explained up above.
03-11-2020 09:17 AM
@aeastet wrote:
Not if you are programming with sound canceling headphones on. 😁
Hah! Didn't think of that. Excellent point. 🙂