Hello,

I presume you are not using scilab 5.5.0, change the function as follows :

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

Le 13/08/2014 14:12, Jens a écrit :
This is small example's output:
  !--error 77
set: falsche Nummer von Eingangsargument(en): 2 nach 3 erwartet.
at line       3 of function waitforkeypress called by :
    select waitforkeypress()
at line     369 of exec file called by :         [last line og script]
exec('G:\Daten\ScilabFun\functionCheck.sce', -1)

Jens
-----------------------------------------------------------------------------------------------------------


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

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 <[hidden email] </user/SendEmail.jtp?type=node&node=4031032&i=0>> 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  <xchange.html>(x,y,'i2f')
   xinfo  <xinfo.html>(msprintf  <msprintf.html>('Event code %d at mouse 
position is (%f,%f)',ibut,x,y))
endfunction

plot2d  <plot2d.html>()
fig  =  gcf  <gcf.html>()  ;
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] </user/SendEmail.jtp?type=node&node=4031030&i=0>> 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] </user/SendEmail.jtp?type=node&node=4031030&i=1>.<a href="orghttp://lists.scilab.org/mailman/listinfo/users"; target="_blank">orghttp://lists.scilab.org/mailman/listinfo/users



_______________________________________________
users mailing list
[hidden email] </user/SendEmail.jtp?type=node&node=4031030&i=2>
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. NAML <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>


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

View this message in context: Re: Recognition of cursor key as input <http://mailinglists.scilab.org/Scilab-users-Recognition-of-cursor-key-as-input-tp4031013p4031031.html> Sent from the Scilab users - Mailing Lists Archives mailing list archive <http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html> at Nabble.com.




_______________________________________________
users mailing list
[hidden email] </user/SendEmail.jtp?type=node&node=4031032&i=1>
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-tp4031013p4031032.html To unsubscribe from [Scilab-users] Recognition of cursor key as input, click here. NAML <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>


------------------------------------------------------------------------
View this message in context: Re: Recognition of cursor key as input <http://mailinglists.scilab.org/Scilab-users-Recognition-of-cursor-key-as-input-tp4031013p4031033.html> Sent from the Scilab users - Mailing Lists Archives mailing list archive <http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html> at Nabble.com.


_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users

Reply via email to