Re: XForms: Simulate Mouse Click

From: spl@eggshell.ucsd.edu
Date: Fri May 18 2001 - 16:08:23 EDT

  • Next message: Marien van Westen: "XForms: Strange behaviour of File Selector"

    # To subscribers of the xforms list from spl@eggshell.ucsd.edu :

    > I have created an App that reads serial
    > packets from a touch screen, converts those
    > packets to X,Y coordinates and places the
    > cursor accordingly using;
    >
    > fl_set_mouse(tscr_x, tscr_y);
    > fl_check_forms();
    >
    > When the user lifts their pointer from
    > the touch screen I would like to
    > simulate a LEFT_MOUSE click to the
    > application the mouse is over.

    I don't think there's any direct XForms support for this. What you'll
    have to do is to create a synthentic XButtonPressedEvent and use
    XSendEvent to send it to yourself:

            XButtonPressedEvent xbpe;

            xbpe.type = XButtonEvent;
            xbpe.serial = 0;
            xbpe.send_event = TRUE;
            xbpe.display = fl_get_display();
            xbpe.window = your_form->window;
            xbpe.root = DefaultRootWindow( fl_get_display() );
            xbpe.subwindow = 0;
            xbpe.time = 0;
            xbpe.x = tscr_x - your_form->x;
            xbpe.y = tscr_y - your_form->y;
            xbpe.x_root = tscr_x;
            xbpe.y_root = tscr_y;
            xbpe.state = Button1Mask;
            xbpe.button = Button1;
            xbpe.same_screen = TRUE;

            XSendEvent( fl_get_display(),
                        your_form->window,
                        TRUE,
                        ButtonPressMask,
                        ( XEvent *) &xbpe );

    I haven't tested this so it may require some mucking about but this
    should work.

                                                            spl
    _________________________________________________
    To unsubscribe, send the message "unsubscribe" to
    xforms-request@bob.usuhs.mil or see
    http://bob.usuhs.mil/mailserv/xforms.html
    XForms Home Page: http://world.std.com/~xforms
    List Archive: http://bob.usuhs.mil/mailserv/list-archives/



    This archive was generated by hypermail 2b29 : Fri May 18 2001 - 16:16:44 EDT