Jump to content

InputMask Functionality for UI Controls


Recommended Posts

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 :P )

Link to comment

That sounds like an interesting idea, although it does have certain dangers. Here are some thoughts:

  1. I assume you're only refering to strings, so an XControl might be better, because it can have properties and its code is encapsulated.
  2. 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.
  3. 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.
  4. 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.
  5. 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. :)

Link to comment

QUOTE (Yair @ Jul 10 2008, 09:10 PM)

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

Link to comment
  • 3 weeks later...

QUOTE (Ton @ Jul 10 2008, 09:25 PM)

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

Link to comment
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.