[Oberon] Re: n-o: How to dynamically insert ListGadgets ?

easlab at absamail.co.za easlab at absamail.co.za
Tue Nov 25 02:39:25 CET 2003


> easlab at absamail.co.za wrote:
> > We know that
> >     Gadgets.Insert  Lists.NewList ~
> > inserts a ListGadget AT THE CARET, but I can't see how to position it
> > on the panel, absolutely or relative to it's 'called by button'.
>
> You probably should send a consume message. 
> Have a look at Chapter5.Text .
>
> Cheers, Edgar
>
> P.S. Warning: no easy reading :-)

Jacques Eloff wrote:
> I agree, not easy reading. Have a look at Example 16 (page 217) of the 
> Oberon Companion. 
> You first need to locate the container object by using the 
> ThisFrame procedure in the Gadgets module. 
> The example uses the mouse pointer coordinates 
> (Oberon.Pointer.X, Oberon.Pointer.Y), but you can use the 
> absolute coordinates of the container to obtain a reference to the 
> Frame that needs to get the Consume message
-- 
OK. Chapter5.Text  Example15 & Example16 both demonstrate the 
method(s) nicely, except when slightly modified (successive refinement)
they appear to be bluff-ghosts.

I've just added a line to re-set C.u, C.v to absolute values, instead of
  those returned by the 'pointer'.
By incrementing the C.u, C.v values, I expect to see the button be
inserted on a diagonal trajectory.
Instead it only moves to the left. Ie. the Y coordinate is not changed.

Similarly the extra extra statement added to Example16 to 
effect the Y coordinate has no effect ?!  
---------------   Compiler.Compile @  \s    
	MODULE Example15;
	
	IMPORT Display, Gadgets, Oberon;

	PROCEDURE Drop*;
	VAR F: Display.Frame; u, v: INTEGER;
		C: Display.ConsumeMsg;
	BEGIN
		Gadgets.ThisFrame(Oberon.Pointer.X, Oberon.Pointer.Y, F, u, v);
				(* gets F, u, v *)
		C.F := F;
		C.id := Display.drop;
		C.obj := Gadgets.CreateObject("BasicGadgets.NewButton");
		C.u := u; C.v := v;	(* relative position in container *)
C.u := 44; C.v := 44;
		Display.Broadcast(C)
	END Drop;

	END Example15.  
Example15.Drop == Insert Button @ F1:star ; modified to insert @ 44,44
--------------- 
	MODULE Example16;

	IMPORT Display, Gadgets, Oberon, Objects;

	PROCEDURE Drop*;
	VAR F: Display.Frame; u, v: INTEGER;
		C: Display.ConsumeMsg; obj, obj1: Objects.Object;
	BEGIN
		Gadgets.ThisFrame(Oberon.Pointer.X, Oberon.Pointer.Y, F, u, v);
				(* get Display.Frame, u, v  *)
		obj := Gadgets.CreateObject("BasicGadgets.NewCheckBox");
		obj1 := Gadgets.CreateObject("BasicGadgets.NewButton");
(*		obj1(Gadgets.Frame).X := obj(Gadgets.Frame).W + 10;	 position it *)
obj1(Gadgets.Frame).Y := obj(Gadgets.Frame).H + 10;	
		obj.slink := obj1;	(* link gadgets together *)
		C.F := F;
		C.id := Display.drop;
		C.obj := obj;
		C.u := u; C.v := v;
		Display.Broadcast(C)
	END Drop;
	
	END Example16. 
Example16.Drop == Insert CheckBox + Button @ star

The documentation tells me that "obj(Gadgets.Frame).W + 10"
is to put the button to the right of the width of the CheckBox,
instead of on top of it. 
So with my modified version I expect to see the button displaced verticaly
w.r.t. the first inserted object.

What am I doing wrong ?


 == Chris Glur.
 




More information about the Oberon mailing list