Would this small example fit your needs ?

function handler(win,x,y,ibut)
    global _keypress
    if or(ibut==(37:40))
        _keypress=ibut;
    end
endfunction

function key=waitforkeypress()
    global _keypress
    set(gcf(),'event_handler','handler','event_handler_enable','on')
    _keypress=0;
    while ~_keypress
        sleep(1)
    end
    set(gcf(),'event_handler_enable','off')
    key=_keypress;
endfunction

while 1
    select waitforkeypress()
    case 37
        disp('left')
    case 38
        disp('up')
    case 39
        disp('right')
    case 40
        disp('down')       
        break
    end
end

S.

Jens <j.s.st...@hslmg.de> a écrit :

Hello,
My event_handler experiments with the Scilab help example in "Event
handler functions" (see below) led to nothing.  I can see the "event" at
the bottom of the graphic window but I cannot arrest it in a variable. I
tried this:

          function my_eventhandler(win, x, y, ibut)  if ibut==-1000 then
return,end  [x,y]=xchange[1](x,y,'i2f')  xinfo[2](msprintf[3]('Event
code %d at mouse position is (%f,%f)',ibut,x,y))endfunction
plot2d[4]()fig = gcf[5]() ;fig.event_handler = 'my_eventhandler'
;fig.event_handler_enable = "on" ;//now://   -  move the mouse over the
graphic window//   -  press and release keys shifted or not with Ctrl
pressed or not//   -  press button, wait a little release//   -  press
and release button//   -  double-click button fig.event_handler_enable =
"off" ; //suppress the event handler                  <a
href="scilab://scilab.execexample/">               <a
href="scilab://scilab.editexample/">

I fear I must retire to 
m=evstr(x_dialog(...)  Jens


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

Am 13.08.2014 11:12, schrieb mottelet [via Scilab / Xcos - Mailing Lists
Archives]:

Hello,

IMHO, the only way to trap a keypress and get the ascii (?) code is to
use the event_handler callback of a figure :

function handler(x,y,ibut)
//
endfunction

f=gcf();
f.event_handler='handler';
​f.event_handle_enable='on';

On my computer, I have the following mapping 

left arrow pressed : ibut=37 (released=-37)
up arrow : 38
right arrow 39
down arrow 40

The problem is that you need to have a figure opened, and that this
figure must have the focus.

S.

   Jens <[hidden email][6]> a écrit :

Hi Samuel,
ASCII representation of up, down etc. would help me if I knew a Scilab
command which puts the ascii value into a variable. input() is
definitely
unable to do so.

Jens

--
View this message in context:

http://mailinglists.scilab.org/Scilab-users-Recognition-of-cursor-key-as-input-tp4031013p4031026.html
Sent from the Scilab users - Mailing Lists Archives mailing list
archive at Nabble.com.
_______________________________________________
users mailing list
[hidden email][7].<a
href="orghttp://lists.scilab.org/mailman/listinfo/users";
target="_blank">orghttp://lists.scilab.org/mailman/listinfo/users


 

_______________________________________________
users mailing list
[hidden email][8]
http://lists.scilab.org/mailman/listinfo/users

-------------------------
       If you reply to this email, your message will be added to the
discussion below:

http://mailinglists.scilab.org/Scilab-users-Recognition-of-cursor-key-as-input-tp4031013p4031030.html
   To unsubscribe from [Scilab-users] Recognition of cursor key as
input, click here[9].
NAML[10]


 

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

  View this message in context: Re: Recognition of cursor key as
input[11]
Sent from the Scilab users - Mailing Lists Archives mailing list
archive[12] at Nabble.com.



Liens:
------
[1] xchange.html
[2] xinfo.html
[3] msprintf.html
[4] plot2d.html
[5] gcf.html
[6] /user/SendEmail.jtp?type=node&node=4031030&i=0
[7] /user/SendEmail.jtp?type=node&node=4031030&i=1
[8] /user/SendEmail.jtp?type=node&node=4031030&i=2
[9]
[10] http://mailinglists.scilab.org/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml [11] http://mailinglists.scilab.org/Scilab-users-Recognition-of-cursor-key-as-input-tp4031013p4031031.html [12] http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users

Reply via email to