How to get the CurrentKey?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get the CurrentKey?

Prometheus
Hello everyone,

I am trying to "translate" my program from Matlab to Octave and I need help:
I have to know, how I can get the keyboard inputs in Octave. I want to
choose a point in many images with "ginput()" and I want to accept/delete it
with "Return" or "Escape" etc...

Matlab:
    currkey=get(gcf,'CurrentKey');
    if strcmp(currkey, 'return')  
            "Do this and that"
    end

I would like to solve this without a GUI :)

Thank you very much.
Prometheus



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: How to get the CurrentKey?

arkkimede
But in octave ginput() works fine....
You can not use it?

Il giorno mer 30 ott 2019 alle ore 11:26 Prometheus <[hidden email]> ha scritto:
Hello everyone,

I am trying to "translate" my program from Matlab to Octave and I need help:
I have to know, how I can get the keyboard inputs in Octave. I want to
choose a point in many images with "ginput()" and I want to accept/delete it
with "Return" or "Escape" etc...

Matlab:
    currkey=get(gcf,'CurrentKey');
    if strcmp(currkey, 'return') 
            "Do this and that"
    end

I would like to solve this without a GUI :)

Thank you very much.
Prometheus



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html




Reply | Threaded
Open this post in threaded view
|

Re: How to get the CurrentKey?

Prometheus
I searched for something to read the keyboard inputs:

*kbhit(1)* is working

Thank you.



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: How to get the CurrentKey?

Prometheus
This post was updated on .
It's me again...

kbhit() is working, but now I have an other problem. If I click on the image
to choose a point, the command window is not selected anymore. I have to
click on the window again. It is annoying.

In Matlab there is "commandwindow" to set the focus on the window again, but
it is not implemented in Octave. Do you have a hint for me?


Here is a example to underline my problem:

clc;
clear all;

printf ("Press 'a' to start\n");

while (1)
  %commandwindow                %Needed: Set focus on command window
  currentkey = kbhit()               %Type 'a' to go on
  if currentkey == 'a'
   
    %imshow('MyExample1.jpg')       %Will be changed in every loop
    hold on
    [xPos, yPos] = ginput(1)                
    plot(xPos, yPos, 'ro');                 %Actual Point
   
  elseif currentkey == 'b'                %Type 'b' to stop
    return;
   
  else

  printf ("Loop is running...\n");
  pause(0.2)
 
  endif

endwhile



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: How to get the CurrentKey?

Prometheus
Does anyone have a tip for me?

I am searching for an octave alternative for "commandwindow".

After I clicked on an image, I want to set the focus on the command window /
promt again, so I can do an input directly. Up to now I have to click on the
windows every time and it's annoying.



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: How to get the CurrentKey?

Pantxo
Prometheus wrote
> Does anyone have a tip for me?
>
> I am searching for an octave alternative for "commandwindow".
>
> --
> Sent from:
> https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

This function has been added in the development branch and will be part of
Octave 6.1:

http://hg.savannah.gnu.org/hgweb/octave/rev/a780677b845c

In Octave 5.1, there is no programmatic way to switch the focus from a
figure to the GUI command window.

Pantxo



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html