[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Mar 29 08:31:46 2000 
Subject:Re: Mouse Button Handling in Pop11 
From:Aaron Sloman See text for reply address 
Volume-ID:1000329.03 

[To reply replace "Aaron.Sloman.XX" with "A.Sloman"]

Nick Arkell <ug56nja@cs.bham.ac.uk> writes:

> Date: Wed, 29 Mar 2000 08:57:42 +0100
>
> I have been trying to build draughts game in pop11 that uses the
> graphical procedures provided by X Windows. I have managed to handle the
> mouse move event and determine the position of the pointer, but I cannot
> handle the mouse_button events:
>
> The program is initialised with rc_start() and rc_setup_mouse(rc_window)

Presumably you are referring to rc_mouse_setup in LIB RC_MOUSE?

> is called just in case. I then set up my handler procedure by the
> following code:
> 	[^on_mouseclick]->rc_button_procedures;
> 	true->rc_mousing;
>
> This sets up my procedure on_mouseclick(widget,event_type,button)
> Unfortunatly, when I try to display the mouse buttton state I get
> <external ptr> printed instead and in the terminal window I get:
> ;;; WARNING - ITEMS LEFT ON THE STACK AFTER CALLBACK BEING IGNORED
> ;;; INVOLVING 0 <procedure do_button_actions>

I suspect that to make this work you will have to look at the code
in rc_mouse and search for existing examples of what you are after.
Also search HELP RC_GRAPHIC for clues.

You can examine the library file by doing, in Ved
    ENTER showlib rc_mouse

My hunch is that in the long run the best way to do all this is to
use an object-oriented package based on objectclass, set up in such
a way that new handlers are created via methods for sub-classes or
instances, with a lot of pre-processing already done, e.g. to
extract coordinates from external pointers.

That is how RCLIB works.
If you are using linux on a PC at home you may have to fetch rclib
from
    http://www.cs.bham.ac.uk/research/poplog/rclib.tar.gz

Install it in $poplocal/local/rclib/
and make $poplocal/local/lib/rclib.p a symbolic link to
    $poplocal/local/rclib/rclib.p
Then you can use it after

    uses rclib

It's already set up in the departmental machines.

You can get a quick run through some of the facilities by looking at
    TEACH rclib_demo.p

Among other things that defines a procedure rc_get_coords for
finding the location at which a mouse pointer is when you press
a button. It can be used in games to get the next move from a user.

> I have programmed GUI systems before, but am new to Unix/Linux and Pop11
> I have searched the Teach/Ref/Help files with pop11 to no avail, can
> anyone help?

To master all the mechanisms (which I have not done) you have to
read a book on the X window system AND lots of documentation in

    $usepop/pop/x/pop/teach
    $usepop/pop/x/pop/help
    $usepop/pop/x/pop/ref
        about 100 files in the ref directory

You may then also have to understand all the external interface
mechanisms in pop-11, described in REF EXTERNAL REF?EXTERNAL_DATA
and REF?DEFSTRUCT

The RCLIB package is designed to enable most users familiar with
pop-11 to create windows, menus, sliders, etc. without knowing all
the low level basics, and without reading a book on X.

E.g. to change the default behaviour for mouse button 3 up events in
windows of class rc_window_object you can do things like:

    define :method rc_button_3_up(win:rc_window_object, x, y, modifiers);

        'Mouse in window ' >< rc_window_title(win) =>

        'at location ' >< [^x ^y] =>

        'Modifier keys down are: ' >< modifiers =>
    enddefine;

Where modifiers will be a string containing any subset of the
characters `c` `s` `m` indicating these keys: Control Shift Meta.

But RCLIB may give you lots more baggage than you need.

At Birmingham RCLIB is pre-compiled as it is used in the Ved/Xved
menu/control panel system provided for new users.

Aaron