Phillip Brooks Posted July 11, 2008 Report Share Posted July 11, 2008 Has anyone ever written a LabVIEW equivalent of the Microsoft Access InputMask? For the last few years I've been writing drivers and TCP comms; I've done very little with UI programming accept for a bit of XControl tinkering. I've switched jobs and now work in a LabVIEW tools group. I need to collect formatted data at a test station, and want to create something that would be general purpose and reusable. I was thinking about using control references and events to check data as its entered into a control. I would use the control 'tip' to store the Input Mask string and maybe use a 'brat' vi that I could drop on the diagram of any UI that contained a control that needed the input mask feature. The brat would search for controls with tips that contain a tagged string, something like InputMask:[(999)000-0000] then dynamically register for KeyDown? or maybe Value Change events from that control, then compare the input to that of the mask. No code yet, just an idea... This would be the second tool I would add to the group (1st tool added was me ) Quote Link to comment
Yair Posted July 11, 2008 Report Share Posted July 11, 2008 That sounds like an interesting idea, although it does have certain dangers. Here are some thoughts: I assume you're only refering to strings, so an XControl might be better, because it can have properties and its code is encapsulated. I would advise against the use of a brat VI here, because it might be difficult to debug. Instead, you can use some sort of action engine which will accept control references and masks. If you do want the brat VI, using tags might be more robust than the tip strip. They're currently private, but I wouldn't be shocked if they were released at some point. The code itself should be relatively simple, but you should be aware that users might paste into the control, so you will need a way to handle that. Filtering Ctrl+V (and Insert) and disabling right clicking should help, at least on Windows. In any case, you should monitor both Key Down? and Key Repeat? and be sure to handle ASCII 9 (backspace) and the Delete key. Also, be sure to handle the left and right keys. P.S. Isn't LabVIEW 7.0 great? No crashing, no waiting. So much fun. Quote Link to comment
LAVA 1.0 Content Posted July 11, 2008 Report Share Posted July 11, 2008 QUOTE (Yair @ Jul 10 2008, 09:10 PM) The code itself should be relatively simple, but you should be aware that users might paste into the control, so you will need a way to handle that. Filtering Ctrl+V (and Insert) and disabling right clicking should help, at least on Windows. This screams XControl, additional there is an application menu tag for pasting, you can filter for it. OK, I took the challenge. A simple start (just using the '0' filter) is uploaded to the LavaCR SVN repository under 8.5x\InputMask, it contains an XControl, with a 'set mask' and 'get mask' method. The project includes 2 examples, one sets the display to a password display, the other one sets a dutch mobile phone mask. Current features: Only uses the 0 filter element (Digit (0 to 9, entry required, plus [+] and minus [–] signs not allowed)) Beeps on error Password To Do: All other filter elements It should overwrite when a key is pressed A right-click gui during edit mode Documentation See here to get the code via SVN Ton Quote Link to comment
LAVA 1.0 Content Posted July 30, 2008 Report Share Posted July 30, 2008 QUOTE (Ton @ Jul 10 2008, 09:25 PM) To Do: All other filter elements It should overwrite when a key is pressed A right-click gui during edit mode Documentation See here to get the code via SVN Ton OK, I have expanded it a little bit. Here's the result with two demo VIs Download File:post-2399-1217352186.llb The source is accessible via SVN. Ton Quote Link to comment
Ton Plomp Posted August 16, 2009 Report Share Posted August 16, 2009 Here is the actual LLB file as referenced: InputMaskXControl.llb Ton Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.