[Scilab-Dev] uimenu.callback_type == -2 ?
Samuel Gougeon
sgougeon at free.fr
Mon Dec 23 10:57:21 CET 2019
Le 07/09/2019 à 13:32, Samuel Gougeon a écrit :
>
> Hello,
>
> While i wasupdating the uimenu_properties page
> <http://bugzilla.scilab.org/16008>, noticeably to document .callback_type,
> i noticed that one of the Figures submenu has a .callback_type set to
> -2 (see below).
> I have found nothing in the uicontrol doc about the meaning of this value.
>
> Would you know what it is, to interpret .callback?
>
> Thanks
> Samuel
>
> --> get(0).showhiddenhandles = "on";
> --> gcf().children(4).children(1)
> ans =
>
> Handle of type "uimenu" with properties:
> ========================================
> Parent: uimenu
> Children: []
> Enable = "on"
> Foregroundcolor = [0,0,0]
> Label = "&Rotation 2D/3D"
> Handle_Visible = "off"
> Visible = "on"
> Callback = "set(get_figure_handle([SCILAB_FIGURE_ID]),
> ''info_message'', ''Right click and drag to rotate.'')"
> Callback_Type = *-*2
> Checked = "off"
> Icon = "transform-rotate"
> Userdata = []
> Tag = ""
>
Le 16/09/2019 à 19:39, tom.kreisel@*.de a écrit :
> Hi Samuel,
>
> I was also struggling with callback_type so I can maybe give some
hints from a programmers perspective.
> Since I am new to Scilab I played around with the master build and
the xcos debug gui, which was not working until I added the
callback_type property 10 to the source code.
> I found in the code:
> /**
> * Abstract class to manage all callbacks.
> *
> * @author Bruno JOFRET
> */
> public class CallBack {
>
> /**
> * Unmanaged command type constant
> */
> public static final int UNTYPED = -1;
> /**
> * Scilab instruction command type constant
> */
> public static final int SCILAB_INSTRUCTION = 0;
> public static final int SCILAB_NOT_INTERRUPTIBLE_INSTRUCTION = 10;
> /**
> * C or Fortran function type constant
> */
> public static final int C_FORTRAN = 1;
> /**
> * Scilab function type constant
> */
> public static final int SCILAB_FUNCTION = 2;
> public static final int SCILAB_NOT_INTERRUPTIBLE_FUNCTION = 12;
> /**
> * Scilab function type constant (not trapped by scilab event
listeners)
> */
> public static final int SCILAB_OUT_OF_XCLICK_AND_XGETMOUSE = -2;
> /**
> * Java function type constant
> */
> public static final int JAVA = 3;
> /**
> * Java function type constant (not trapped by scilab event
listeners)
> */
> public static final int JAVA_OUT_OF_XCLICK_AND_XGETMOUSE = -3;
>
> /**
> * Scilab instruction without GCBO setting (used in case of
pause/resume/abort)
> */
> public static final int SCILAB_INSTRUCTION_WITHOUT_GCBO = 4;
>
> [...]
>
> so -2 means SCILAB_OUT_OF_XCLICK_AND_XGETMOUSE:
>
> If this type is used, the actionPerformed method of the
ScilabCallbackClass is overriden to just call the callback:
> /**
> * Callback Factory to easily create a callback
> * just like in scilab.
> * WARNING : this callback will be ignored by xclick & xgetmouse
> * @param command : the command to execute.
> * @return a usable Scilab callback
> */
> public static ScilabCallBack createOutOfXclickAndXgetmouse(String
command) {
> return (new ScilabCallBack(command) {
>
> private static final long serialVersionUID =
-7286803341046313407L;
>
> public void callBack() {
> Thread launchMe = new Thread() {
> public void run() {
> InterpreterManagement.putCommandInScilabQueue(getCommand());
> }
> };
> launchMe.start();
> }
>
> /**
> * To match the standard Java Action management.
> * @see
java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
> * @param e The event that launch the callback.
> */
> public void actionPerformed(ActionEvent e) {
> callBack();
> }
> });
> }
>
> The usual implementation uses a GlobalEventWatcher, I guess this
implements the xclick and xgetmouse features.
>
> /**
> * To match the standard Java Action management.
> * @see
java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
> * @param e The event that launch the callback.
> */
> public void actionPerformed(ActionEvent e) {
> if (!GlobalEventWatcher.isCatchingCallback()) {
> callBack();
> } else {
> if (this.callback.getCommand() != null) {
> GlobalEventFilter.filterCallback(this.callback.getCommand());
> }
> }
> }
>
> so if you use -2 as type, xclick and xgetmouse listener will not be
informed of your mouseclick.
>
> there are also other integers not mentioned in the docu.
>
> Would have liked to post this into the list, but currently the server
rejects my email address...
>
> Hope this might be useful..
>
> KR Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/dev/attachments/20191223/a3cca87b/attachment.htm>
More information about the dev
mailing list