From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Prevent Legend edit

Solved!
Go to solution

Ok, this is annoying me now.

 

I have a waveform graph in my current application. I use a lot of programmatic control to get it to adapt and display just the way I like it on the front panel (the application is meant to very customisable for the user). The waveform graph displays any number of plots from 1 to 12 simultaneously, and automatically adapts sensible things like axes labels and legend size to show those plots I want to show.

 

Now. I don't want the user to be able to edit the name of the plots in the Legend. However, if I use the Disable Legend property, this disables the whole legend resulting in the user not being able to change the plot style/colour/symbols etc. As I need to keep this level of customisation I therefore need to keep the legend enabled, but somehow prevent them from being able to change the plot name.

 

I can't detect plot name changes programmatically, so I can't restore them if the user makes any changes. Therefore I'm stuck. Smiley Sad

 

Any ideas anyone

 

legenddisable.png

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 1 of 6
(3,819 Views)
Solution
Accepted by topic author Thoric

What you can do is place a decoration box over the name part of the legend.  Of course that would hide the names.  But if you use the paint brush and color picker and select it for Transparent and paing the decoration, now it will be invisible and you can see through it.  When running, any cursor action will be acting on the decoration rather than the legend names preventing a person from interacting with it.

 

I'm sure there is a way to detect changes to the plot name programmatically.  At the beginning of your program, you could iterate through the plots and create an array of all the names.  During running, you could periodically do the same thing and compare the new array of names to the previous name.  If they are different, you know you have a change and you have the previous name still stored to change it back to. 

 

However, I would just go with the transparent box method to prevent changes.

Message Edited by Ravens Fan on 06-04-2009 09:39 PM
Message 2 of 6
(3,808 Views)

You could register for a key down? event on the plot I think LabVIEW returns a reference to the subsystem (legend) of that item, and you could ignore the key down event.

Or you could write your own legend tool, the easiest is to use the normal legend and shrink the 'name' part to 0 pixels and place a table at that location.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 3 of 6
(3,802 Views)

Happy Friday to you all! I really enjoyed Ravens Fan's resourceful workaround... the simpliest solutions are often the best!!

 

I would recommend using RavenFan's workaround, but for future reference here is an example showing how to programmatically modify multi-plot names. And a link to the KB article which inspired it.

 

Best wishes,

 

How Do I Programmatically Modify the Palettes and Legends on My Graph or Chart?

http://digital.ni.com/public.nsf/allkb/A0525AF9D64408F186256BFB005970EB?OpenDocument

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
0 Kudos
Message 4 of 6
(3,784 Views)

Thanks Rich,

 

By the way, that knowledge base article is another one of those that have image links to the ae.natinst.com website that the general public does not have access to.

 

See this thread for a recent conversation about this.

0 Kudos
Message 5 of 6
(3,767 Views)

Thanks for the ideas everyone.

Ravens Fan - I would normally put a transparent box over the text, but the chart size changes with the front panel, and the legend changes size too, so I'd need to continually resize the box. I presume by box, you mean a classic decoration, so I'd have to be quite careful in returning a reference to it to allow property changes. I'm sure that possible, but I preferably need a quick solution.

 

TonP - I've had a play around, but all I can return is a reference to the chart within an event case, not the legend. If I refuse the key down? filter event every time, then my users won't be able to change scale ranges with the keyboard. I definitely need to check the focus object is the legend, but I can't see a way to do that. Any ideas?

 

Rich - Yes, I'm aware of programmatic control of charts, apologies if my opening message was not clear.

 

Am I the only one tired of creating lengthy workarounds to artifically construct behaviours I expect to be quite standard in LabVIEW? All I want is to stop a user changing plot names, but allow them to modify everything else Smiley Sad

 

Looks like I'm going to have to start using user tags, decorations, and property nodes again...

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 6 of 6
(3,750 Views)