LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with keyboard Shortcuts and editing

LV 2013, Win7

 

I'm an old hand at LabVIEW, but fairly new at using menus.

 

I have a window, where the user opens a file and edits it, and can save it.

 

What is actually edited is an array of clusters, each cluster contains several items. The user adjusts the array index and changes things around to suit.

 

There is an EDIT menu in the window, with the usual CUT COPY PASTE items in it.

 

The FILE menu has a SAVE item, with a Ctrl-S shortcut.


This pic shows the code attached to the MENU ACTIVATION? event, called when the user clicks on the menu bar, or hits a shortcut combo.

 

Note the WORKAROUND section:

 

Editing.PNG

 

 

The comment explains the point of the DUMMY - the problem is that LabVIEW (improperly, IMO) fails to terminate editing on a control before handling a shortcut key.  The value read is the old value before the START of editing.   Unless I force the focus somewhere else, then the file saved does not necessarily include the changes made to the field.

 

The above workaround works to solve that problem - but it introduces another.

 

I discovered that the EDIT menu will not work (neither mouse nor keyboard shortcuts).

 

The reason is simple: the edit menu works on the currently FOCUSED control, and since I'm changing the focus AWAY from the text control to a boolean DUMMY, the edit menu doesn't apply, so it gets disabled.

 

So, how do I get out of this?

 

Do I have to set all the fields to UPDATE VALUE WHILE TYPING, and lose the workaround?

 

Do I have to search for the focus, switch it to the dummy, then switch it back before saving?

 

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 1 of 12
(4,166 Views)

The UPDATE VALUE WHILE TYPING idea won't work in all cases.

 

If I have a NUMERIC field, and I select the value 12.34 and start typing:  56.78^S, I expect to see 56.78 stored in the file.

But the same basic issue shows up - LV does NOT end editing on the control, so what gets saved is the old value 12.34.

 

There is no UPDATE VALUE WHILE TYPING for numeric controls.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 12
(4,159 Views)

The comment explains the point of the DUMMY - the problem is that LabVIEW (improperly, IMO) fails to terminate editing on a control before handling a shortcut key.

 

It's your user's job to commit the change by hit the Enter Key.

If they don't, then the old value will be used.

 

Alternative, if the control is a string, you can force the control to Update While Typing.

 

George Zou
0 Kudos
Message 3 of 12
(4,150 Views)

Instead of a dummy button, you can give your user a real button with a boolean text "Finish Editing".

 So your user know they have to hit the button to commit the changes.

 

George Zou
0 Kudos
Message 4 of 12
(4,146 Views)

It's your user's job to commit the change by hit the Enter Key.

 

But there are a thousand ways to commit the change - Hit ENTER, Tab to another control, click on another control, click outside the control, switch to a different program, etc.

 

But using a shortcut key is not one of them.

 

If you open a notepad file and type ABCDE^S, you get a file with ABCDE in it, like you'd expect.

 

It seems unnatural here in this case.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 5 of 12
(4,138 Views)

If you open a notepad file and type ABCDE^S, you get a file with ABCDE in it, like you'd expect.

 

That's similar to a string control with "Update While Typing".

 

 

George Zou
0 Kudos
Message 6 of 12
(4,130 Views)

That's similar to a string control with "Update While Typing".

 

I understand that.  But there's no such option for numeric controls, combo boxes, maybe others.

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 7 of 12
(4,124 Views)

 

If you open a notepad file and type ABCDE^S, you get a file with ABCDE in it, like you'd expect.

 

Not an good example. 

That's similar to a string control with "Update While Typing".

 

 

 

 

 

George Zou
0 Kudos
Message 8 of 12
(4,117 Views)

Instead of dummy.KeyFocus at the menu activate event,

make a control.KeyFocus + dummy.KeyFocus when you process the menu selection.

 

 

George Zou
0 Kudos
Message 9 of 12
(4,102 Views)

Instead of dummy.KeyFocus at the menu activate event,

make a control.KeyFocus + dummy.KeyFocus when you process the menu selection.

 

 

But in the case of the EDIT menu (with APP_CUT, etc. tags), I don't process the menu selection - that's all behind the scenes and I don't have any code to handle it. 

 

A Ctrl-X never gets to my code, (unless I install a MENU SELECTION (APP) handler, which I don't have now.

 

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 10 of 12
(4,098 Views)