How to execute Ctrl+Right Click in GUIDE listbox

3 Ansichten (letzte 30 Tage)
Alborz Sakhaei
Alborz Sakhaei am 14 Nov. 2016
Bearbeitet: Alborz Sakhaei am 20 Apr. 2017
I have a simple GUIDE with one listbox. This is what I am trying to do with the listbox:
  • If Right-Click on an item --> Add word "Right" to the selected item string and if Right-Click again remove the added "Right" from the string.
  • If Crtl+Right-Click on an item --> Add word "Ctrl+Right" to the selected item string and if Ctrl+Right-Click again remove the added "Ctrl+Right" from the string.
I'm using figure "currentkey" property to get status of "Ctrl" key (pressed or not). Everything works fine except that once I Ctrl+Right-Click the Ctrl key "pressed" status remains latched (which makes sense given that "currentkey" property does not update until another key is being pressed). The problem is that after this when I Right-Click (only), although the Ctrl key is not pressed, the Ctrl+Right-Click executes (because of latched Ctrl key pressed status) which is not as desired. So, how can I get the Ctrl key "pressed" status update in "real time" i.e. for that very moment that I'm Right-Clicking on an item in the listbox?
PS: I have also tried other figure properties such as "selectiontype" , "KeyPressFcn" , "KeyReleaseFcn" , "WindowKeyPressFcn" , "WindowKeyReleaseFcn" non of which helped me resolve the Ctrl+Righ-Click issue.
Code is attached.

Akzeptierte Antwort

Alborz Sakhaei
Alborz Sakhaei am 14 Nov. 2016
Bearbeitet: Alborz Sakhaei am 20 Apr. 2017
Using "currentmodifier" instead of "currentkey" solved the problem.

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by