- Dragging -Success!

From: Douglas G. Danforth <"Douglas>
Date: Sun, 24 Sep 2006 10:53:56 -0400

----boundary-LibPST-iamunique-982978272_-_-
Content-type: text/plain

Dragging now works!

I had to resort to Services.Action to allow the system to breath.
That is, a call to my handleMouse would ask for a Views.Update and
then immediately return to process Ports.Input which would again
call my handleMouse. But this actually gave no cycles to the system
to let the Views.Update messages flow through the system.

Hence I implemented the code as follows:

        Action = POINTER TO RECORD(Services.Action)
                        view: View;
                        f: Views.Frame;
                        msg: Controllers.TrackMsg;
                        x,y: INTEGER;
                        END;

    PROCEDURE (a: Action) Do;
        VAR isDown: BOOLEAN;
    BEGIN
        IF (a.msg.x # a.x) OR (a.msg.y # a.y) THEN
            a.view.handleMouse(a.msg.x DIV a.f.unit, a.msg.y DIV
a.f.unit, a.msg.modifiers);
            a.x := a.msg.x; a.y := a.msg.y;
        END;
        a.f.Input(a.msg.x, a.msg.y, a.msg.modifiers, isDown);
        IF isDown THEN Services.DoLater(a, Services.now) END
    END Do;
   
    PROCEDURE (v: View) HandleCtrlMsg (f: Views.Frame; VAR msg:
Controllers.Message; VAR focus: Views.View);
        VAR x, y, w, h: INTEGER; isDown: BOOLEAN; action: Action;
    BEGIN
        (* here comes the behavior which is specific to this wrapper -
            it modifies the wrapped view's behavior *)
        IF (msg IS Controllers.EditMsg) & (v.handleKey # NIL) THEN
            WITH msg: Controllers.EditMsg DO
                IF (msg.op = Controllers.pasteChar) THEN
v.handleKey(msg.char) END
            END
        ELSIF (msg IS Controllers.TrackMsg) & (v.handleMouse # NIL) THEN
            WITH msg: Controllers.TrackMsg DO
                v.handleMouse(msg.x DIV f.unit, msg.y DIV f.unit,
msg.modifiers);
                x := msg.x; y := msg.y;
                f.Input(msg.x, msg.y, msg.modifiers, isDown);
                IF isDown THEN
                    NEW(action);
                    action.view := v;
                    action.f := f;
                    action.msg := msg;
                    action.x := x; action.y := y;
                    Services.DoLater(action, Services.now)
                END
            END
        END;
        focus := v.inner (* forward all controller messages to
wrapped view *)
    END HandleCtrlMsg;

-Doug Danforth

--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy


----boundary-LibPST-iamunique-982978272_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIERyYWdnaW5nIG5vdyB3b3JrcyFccGFyDQpccGFy
DQpJIGhhZCB0byByZXNvcnQgdG8gU2VydmljZXMuQWN0aW9uIHRvIGFsbG93IHRoZSBzeXN0ZW0g
dG8gYnJlYXRoLlxwYXINClRoYXQgaXMsIGEgY2FsbCB0byBteSBoYW5kbGVNb3VzZSB3b3VsZCBh
c2sgZm9yIGEgVmlld3MuVXBkYXRlIGFuZFxwYXINCnRoZW4gaW1tZWRpYXRlbHkgcmV0dXJuIHRv
IHByb2Nlc3MgUG9ydHMuSW5wdXQgd2hpY2ggd291bGQgYWdhaW5ccGFyDQpjYWxsIG15IGhhbmRs
ZU1vdXNlLiAgQnV0IHRoaXMgYWN0dWFsbHkgZ2F2ZSBubyBjeWNsZXMgdG8gdGhlIHN5c3RlbVxw
YXINCnRvIGxldCB0aGUgVmlld3MuVXBkYXRlIG1lc3NhZ2VzIGZsb3cgdGhyb3VnaCB0aGUgc3lz
dGVtLlxwYXINClxwYXINCkhlbmNlIEkgaW1wbGVtZW50ZWQgdGhlIGNvZGUgYXMgZm9sbG93czpc
cGFyDQpccGFyDQogICAgICAgIEFjdGlvbiA9ICAgIFBPSU5URVIgVE8gUkVDT1JEKFNlcnZpY2Vz
LkFjdGlvbilccGFyDQogICAgICAgICAgICAgICAgICAgICAgICB2aWV3OiAgICBWaWV3O1xwYXIN
CiAgICAgICAgICAgICAgICAgICAgICAgIGY6ICAgIFZpZXdzLkZyYW1lO1xwYXINCiAgICAgICAg
ICAgICAgICAgICAgICAgIG1zZzogICAgQ29udHJvbGxlcnMuVHJhY2tNc2c7XHBhcg0KICAgICAg
ICAgICAgICAgICAgICAgICAgeCx5OiAgICBJTlRFR0VSO1xwYXINCiAgICAgICAgICAgICAgICAg
ICAgICAgIEVORDtccGFyDQpccGFyDQogICAgUFJPQ0VEVVJFIChhOiBBY3Rpb24pIERvO1xwYXIN
CiAgICAgICAgVkFSIGlzRG93bjogQk9PTEVBTjtccGFyDQogICAgQkVHSU5ccGFyDQogICAgICAg
IElGIChhLm1zZy54ICMgIGEueCkgT1IgKGEubXNnLnkgIyBhLnkpIFRIRU5ccGFyDQogICAgICAg
ICAgICBhLnZpZXcuaGFuZGxlTW91c2UoYS5tc2cueCBESVYgYS5mLnVuaXQsIGEubXNnLnkgRElW
IFxwYXINCmEuZi51bml0LCBhLm1zZy5tb2RpZmllcnMpO1xwYXINCiAgICAgICAgICAgIGEueCA6
PSBhLm1zZy54OyBhLnkgOj0gYS5tc2cueTtccGFyDQogICAgICAgIEVORDtccGFyDQogICAgICAg
IGEuZi5JbnB1dChhLm1zZy54LCBhLm1zZy55LCBhLm1zZy5tb2RpZmllcnMsIGlzRG93bik7XHBh
cg0KICAgICAgICBJRiBpc0Rvd24gVEhFTiBTZXJ2aWNlcy5Eb0xhdGVyKGEsIFNlcnZpY2VzLm5v
dykgRU5EXHBhcg0KICAgIEVORCBEbztccGFyDQogICBccGFyDQogICAgUFJPQ0VEVVJFICh2OiBW
aWV3KSBIYW5kbGVDdHJsTXNnIChmOiBWaWV3cy5Gcm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ngsIG1zZy55LCBtc2cubW9kaWZpZXJzLCBpc0Rvd24pO1xwYXINCiAgICAgICAgICAgICAgICBJ
RiBpc0Rvd24gVEhFTlxwYXINCiAgICAgICAgICAgICAgICAgICAgTkVXKGFjdGlvbik7XHBhcg0K
ICAgICAgICAgICAgICAgICAgICBhY3Rpb24udmlldyA6PSB2O1xwYXINCiAgICAgICAgICAgICAg
ICAgICAgYWN0aW9uLmYgOj0gZjtccGFyDQogICAgICAgICAgICAgICAgICAgIGFjdGlvbi5tc2cg
Oj0gbXNnO1xwYXINCiAgICAgICAgICAgICAgICAgICAgYWN0aW9uLnggOj0geDsgYWN0aW9uLnkg
Oj0geTtccGFyDQogICAgICAgICAgICAgICAgICAgIFNlcnZpY2VzLkRvTGF0ZXIoYWN0aW9uLCBT
ZXJ2aWNlcy5ub3cpXHBhcg0KICAgICAgICAgICAgICAgIEVORFxwYXINCiAgICAgICAgICAgIEVO
RFxwYXINCiAgICAgICAgRU5EO1xwYXINCiAgICAgICAgZm9jdXMgOj0gdi5pbm5lciAgICAoKiBm
b3J3YXJkIGFsbCBjb250cm9sbGVyIG1lc3NhZ2VzIHRvIFxwYXINCndyYXBwZWQgdmlldyAqKVxw
YXINCiAgICBFTkQgSGFuZGxlQ3RybE1zZztccGFyDQpccGFyDQotRG91ZyBEYW5mb3J0aFxwYXIN
ClxwYXINCi0tLSBCbGFja0JveFxwYXINCi0tLSBzZW5kIHN1YmplY3QgSEVMUCBvciBVTlNVQlND
UklCRSB0byBibGFja2JveEBvYmVyb24uY2h9fQBoY2cwS1BpQnQK


----boundary-LibPST-iamunique-982978272_-_---
Received on Sun Sep 24 2006 - 16:53:56 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:32:15 UTC