LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Close VI if mouse click occurs outside of the VI

Solved!
Go to solution
I want a my VI to close automatically if the user clicks the mouse outside of it (i.e. not inside the panel bounds).  Is this behavior possible?
Quentin "Q" Alldredge

Chief LabVIEW Architect, Testeract | Owner, Q Software Innovations, LLC (QSI)
Director, GCentral | Admin, LabVIEW Wiki | Creator, The QControl Toolkit
Certified LabVIEW Architect | LabVIEW Champion | NI Alliance Partner



Message 1 of 5
(4,636 Views)

Q,

 

there is, at least to my knowledge, not such function directly available in LabVIEW. The event structure for instance only supplies you with events which are created within the LabVIEW window.

What LabVIEW is doing in the background is simplified to this:

The Operating System (OS) detects an interaction of an HMI-device (like the mouse) and queues this event in the event-queue. LabVIEW looks into this queue and fetches all events which are connected with LabVIEW windows. Most (but not all) of those events are available in the event structure. If LabVIEW finished processing that given event, it is usually 'requeued' in the windows event queue. Afterwords, Windows processes that event and deletes it.

 

The event you want to track is not meant for any LabVIEW window and therefore will not be available in LabVIEW using the standard mechanics. But still, you can use the API from the OS in order to get infos about that. For Windows, that API is called "Windows Software Developement Kit" or shortended: Windows SDK. The SDK consists of many DLLs which can be used in any programming language. So you can use the SDK to

- get info if a mouseclick occured

- if a mouseclick occured you can check if it occured inside or outside of a LabVIEW window.

 

But that will definetly create a lot of overhead in you application and maybe therefore create performance issues.....

 

hope this helps,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 5
(4,632 Views)
Solution
Accepted by topic author TheQ

If you aren't family with Window API/SDK.  G Toolbox can have you to capture the the mouse click event outside LabVIEW window (using Window API).

 

If you don't mind poll, there is an easy approach (see attached image):

 


Message Edited by zou on 10-10-2008 12:25 PM
George Zou
Message 3 of 5
(4,603 Views)

Some other ideas that may/or may not work...: 

 

  • Maybe there is a way for the VI to find out if it still has key focus. It could poll that once in a while and close itself if it is no longer true.
  • You could maybe also poll the "is frontmost" property and let it close itself if this is no longer true.
  • Maybe you can play with the "Floating/Auto-Hide" property? (from the help: The front panel window is floating and when you switch from LabVIEW to another application, the window does not appear.)
Message 4 of 5
(4,594 Views)

Thanks zou,

 

I just compared axis info to my panel location.  When a mouse button was clicked and the click was outside the panel, the exit state would be triggered.  One small problem is a click inside the panel, when dragged outside of it is still considered a click out side the panel.  I might be able to compensate for this by using different events.

 

Also, thanks to Altenbach

Quentin "Q" Alldredge

Chief LabVIEW Architect, Testeract | Owner, Q Software Innovations, LLC (QSI)
Director, GCentral | Admin, LabVIEW Wiki | Creator, The QControl Toolkit
Certified LabVIEW Architect | LabVIEW Champion | NI Alliance Partner



0 Kudos
Message 5 of 5
(4,588 Views)