Jump to content

Custom Controls


BrokenArrow

Recommended Posts

Hello all! My first post :rolleyes: , although I've lurked a bit. This is a great site, and I look forward to participating. On to the question:

I'm looking for tips and tricks, examples, and methods of creating custom controls.

In my position, I have to do this a lot, and have had some success, but the code is messy. A typical example of something I've implemeted a dozen times is a simple octagon, which will turn red on the side you click on. In my case, this simple looking device contains multiple custom controls, transparent buttons, and Visible property nodes. This takes up a lot of space, and I'm wondering if thinks there's an easier way. I'll post my octagon when I'm on my other computer.

Anyway, any tips are appreciated, or links to examples. Please note I use 7.1 as default because I don't always have access to 8.X.

- Richard

Link to comment

Richard,

Welcome to LAVA!

I'm sure you'll find this a great place to discuss user interface and custom control tricks. In fact, Michael (LAVA's admin) is a wizard in this area (as are many of LAVA's members) and, every once in a while, he shares some of his secrets.

<shameless plug>

Also, if you keep your eye on LAVA's general annoucements forum, we'll be posting links to periodic articles written by Michael (and others) about how some VIPM user interface features are implemented. In the future, this will include some exciting stuff on XControls.

</shameless plug>

Cheers,

-Jim

Link to comment

You might wish to check out the picture control which can allow you to do basically anything you want. There are several threads both here and on the NI forums with all kinds of examples.

In the case of your octagon example, I would suggest making the background of the control transparent and use the Mouse Down event to feed a reference and a position into a subVI which will control this. If you really want to abstract this, you can run this is as a seperate process which will register the mouse down event, but you will also need some way to stop the process.

This can allow you to create any kind of control you like, but you won't see the control at edit time and the control itself will not have any value.

Link to comment

QUOTE(Jim Kring @ Feb 18 2007, 02:25 PM)

Yes, that's me Jim! Just never really ventured outside NI too much until now. Glad I did -- responses on a Sunday!

BTW, I'm a big fan, and appreciate your response. VIPM rocks!

-------------

Thanks for the responses. Crelf, my run arrow is broken more often than not, hence the name. ;)

--------------

Yen, I've used the MouseDown event in the past, but it gave me trouble on EXE's. I think it had to do with resizing the window before I made the VI - the mouse no longer had a reference. That experience put a bad taste in my mouth, and I haven't gone back, but I'm willing to try again. My upcomming projects will involve schematic-based user controls --- the "buttons" will look nothing like buttons -- so the Mouse Down is a good vehicle for that. Thanks for reminding me.

The Picture Ring is great, but you can't "click on it".

I hope to have my Octagon downloaded soon so you guys can laugh at.. I mean help me :yes:

Link to comment

QUOTE(BrokenArrow @ Feb 18 2007, 10:18 PM)

...responses on a Sunday!
Don't beat the NI forums. This place is usually more active over the second half of the weekend, but there are some users there who will post answers in the weekend as well.

QUOTE

Yen, I've used the MouseDown event in the past, but it gave me trouble on EXE's.

The Picture Ring is great, but you can't "click on it".

I'm not sure which problem you've had. For detecting click positions you should use the front panel coordinates you can get from the property nodes and the position and size of the control itself. The size and position of the window should have nothing to do with it.

Note that I refered to the picture control, not the picture ring, but in any case, even if you did mean the picture control, you can most definitely "click on it", you just need to use the data from the mouse down event to find out where. If by "click" you mean that it is not a control which will respond at all times to your interaction, you are absolutely correct (although maybe it would work with XControls. I don't have any experience with them myself).

Link to comment

QUOTE(yen @ Feb 18 2007, 05:18 PM)

Wouldn't dream of it! That forum has saved me time and angst more times than I can count.

QUOTE(yen @ Feb 18 2007, 05:18 PM)

I'm not sure which problem you've had. For detecting click positions you should use the front panel coordinates you can get from the property nodes....

Nope, didn't do that. It ws the physical resizing of the window, and moving of some controls :nono: that caused my mouse clicks to be ill-received once I EXE'd it all. Had I used PN's, I'd been golden.

===================

OK, so attached is a sample of a custom control that is in one of my (older) programs. I've extrated the fluff and esoteric junk, and left it with just the basic octagon I mentioned. This is pretty typical Property Node Hell that I encounter when doing this stuff. There's NINE total custom controls, consisting of the basic octagon and eight red lines that appear on the octagon as things are selected. The important feature (and the hardest to do) is to let the user click on any side of the octagon to select that side. The users don't like to select from a drop-down box - which is easy. Anyway, you'll get the idea. How would a "real pro" ;) do this?

Richard

Link to comment

Thanks to all - excellent suggestions - you've got me thinking outside the box a little. I still think the transparent buttons on top of custom indicators is the most obvious route, although probably the most messy insofar as the sheer mass of back panel things to keep track of. I have, in the past, bundled these things into VI's, but the references are almost as clumsy, and editing is a chore. Also, there's the anti Property Node (cousin to anti Local Variable) thing nagging at me.

Ah I see Lava has it's own User Interface section - should have put this there! <noob>

Anybody want to make my vi :thumbup: prettier?

Link to comment
  • 1 year later...

This is pretty much what the User Interface forum is for. We also have an XControls category and a User Interface category in the CR. We also have User Interface Portal on the Wiki which includes content on XControls.

If anyone has any techniques or ideas to contribute along these lines please use the above mentioned resources to post your content. Especially the Wiki.

Link to comment

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.