Setting Focus Into Field Control

Cuno Pfister (101644.1636@compuserve.com)
Thu, 24 Sep 1998 03:04:34 -0400

>However, I wish to provide a menu item which when selected, will move the
>focus to a predetermined Field within the document. I can calculate the
>position of this Control view that is to obtain the focus, but I am not
>able to develop a program fragment that would set the focus (Caret) inside
>the desired Field.

There are two points that are not obvious from the standard Obx examples:
how to get a focus container that is in mask mode, and how to set the
focus
of a specific view in this container. The module below demonstrates these
two points. It focuses a control with the label "magic string".

I hope this helps

With best regards

Cuno Pfister

Oberon microsystems, Inc.

MODULE TestNav;

IMPORT Dialog, Views, Containers, Controls, TextModels,
TextControllers;

PROCEDURE Do*;
VAR c: Containers.Controller; rd: TextModels.Reader; v:
Views.View; ctrl: Controls.Control;
BEGIN
c := Containers.Focus();
IF c # NIL THEN
WITH c: TextControllers.Controller DO
rd := c.text.NewReader(NIL);
rd.ReadView(v);
WHILE v # NIL DO
WITH v: Controls.Control DO
IF v.label = "magic
string"
THEN ctrl := v; Dialog.Beep END
ELSE
END;
rd.ReadView(v)
END;
IF ctrl # NIL THEN
c.SetFocus(ctrl)
END
ELSE
END
END
END Do;

END TestNav.

"Set Focus" "" "TestNav.Do" ""