Re: [BLACKBOX] Dragging a control

From: [at]} <Wojtek>
Date: Sun, 24 Jul 2011 00:57:08 -0400

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

I created an empty form and added a button to it. I can drag it around.

Perhaps you can have a look at the message handlers of the controls
supplied with the BB system?

W.

> Folks,
>
> Here is another problem I am struggling with.
>
> I have created a simple control that is just a small
> square. I want to drag it around in a form or view.
> How can I do that?
>
> I have read the documentation on drag &amp; drop but
> it is obscure to me.
>
> I would think that since windows are easily drag
> (repositioned) that doing the same with a control
> should also be easy but I don't see how.
>
> Here is my naive attempt that knows the control is
> moused (its color inverts when pressed) but does
> not move. The MoveFrame is my effort to move
> the control.
>
> PROCEDURE (v: View) MoveFrame (f: Views.Frame; w, h, x, y, rx,
> ry: INTEGER), NEW;
> BEGIN
> (*Keep the center of the dragger at tthe mouse position*)
> Controllers.Drop(x-(w DIV 2), y-(h DIV 2), f, x, y, v, TRUE,
> w, h, rx, ry);
> END MoveFrame;
>
> PROCEDURE (v: View) HandleCtrlMsg (
> f: Views.Frame; VAR msg: Controllers.Message; VAR focus:
> Views.View
> );
> VAR rx, ry, x, y, w, h, res: INTEGER; modifiers: SET;
> inside, isDown: BOOLEAN;
> BEGIN
> WITH msg: Controllers.TrackMsg DO (* mouse button was
> pressed *)
> v.context.GetSize(w, h);
> f.Input(rx, ry, modifiers, isDown); (*(rx,ry) is first
> click point*)
> f.MarkRect(0, 0, w, h, Ports.fill, Ports.invert,
> Ports.show); inside := TRUE;
> REPEAT (* mouse tracking loop *)
> f.Input(x, y, modifiers, isDown);
> IF inside # (x >= 0) &amp; (y >= 0) &amp; (x < w)
> &amp; (y < h) THEN (* toggle state *)
> inside := ~inside; f.MarkRect(0, 0, w, h,
> Ports.fill, Ports.invert, inside)
> END;
> IF inside THEN v.MoveFrame(f, w, h, x, y, rx, ry)
> END;
> UNTIL ~isDown;
> IF inside THEN (* mouse was released inside the
> control *)
> f.MarkRect(0, 0, w, h, Ports.fill, Ports.invert,
> Ports.hide);
> IF v.link # "" THEN
> Dialog.Call(v.link, "", res) (* interpret and
> execute the string in v.link *)
> END
> END
> ELSE (* ignore other messages *)
> END
> END HandleCtrlMsg;
>
> -Doug Danforth
>
>
> ---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to
> LISTSERV{([at]})nowhere.xy


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-1166822125_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIEkgY3JlYXRlZCBhbiBlbXB0eSBmb3JtIGFuZCBh
ZGRlZCBhIGJ1dHRvbiB0byBpdC4gSSBjYW4gZHJhZyBpdCBhcm91bmQuXHBhcg0KXHBhcg0KUGVy
aGFwcyB5b3UgY2FuIGhhdmUgYSBsb29rIGF0IHRoZSBtZXNzYWdlIGhhbmRsZXJzIG9mIHRoZSBj
b250cm9sc1xwYXINCnN1cHBsaWVkIHdpdGggdGhlIEJCIHN5c3RlbT9ccGFyDQpccGFyDQpXLlxw
YXINClxwYXINCj4gICAgICAgICAgICAgICAgICAgICAgRm9sa3MsXHBhcg0KPlxwYXINCj4gICAg
ICBIZXJlIGlzIGFub3RoZXIgcHJvYmxlbSBJIGFtIHN0cnVnZ2xpbmcgd2l0aC5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BoLCBQb3J0cy5maWxsLCBQb3J0cy5pbnZlcnQsXHBhcg0KPiBQb3J0cy5zaG93KTsgaW5z
aWRlIDo9IFRSVUU7XHBhcg0KPiAgICAgICAgICAgICAgICAgIFJFUEVBVCAgICAoKiBtb3VzZSB0
cmFja2luZyBsb29wICopXHBhcg0KPiAgICAgICAgICAgICAgICAgICAgICBmLklucHV0KHgsIHks
IG1vZGlmaWVycywgaXNEb3duKTtccGFyDQo+ICAgICAgICAgICAgICAgICAgICAgIElGIGluc2lk
ZSAjICh4ID49IDApICZhbXA7ICh5ID49IDApICZhbXA7ICh4ICAgICA8IHcpXHBhcg0KPiAmYW1w
OyAoeSA8IGgpIFRIRU4gICAgKCogdG9nZ2xlIHN0YXRlICopXHBhcg0KPiAgICAgICAgICAgICAg
ICAgICAgICAgICAgaW5zaWRlIDo9IH5pbnNpZGU7IGYuTWFya1JlY3QoMCwgMCwgdywgaCxccGFy
DQo+IFBvcnRzLmZpbGwsIFBvcnRzLmludmVydCwgaW5zaWRlKVxwYXINCj4gICAgICAgICAgICAg
ICAgICAgICAgRU5EO1xwYXINCj4gICAgICAgICAgICAgICAgICAgICAgSUYgaW5zaWRlIFRIRU4g
di5Nb3ZlRnJhbWUoZiwgdywgaCwgeCwgeSwgcngsIHJ5KVxwYXINCj4gRU5EO1xwYXINCj4gICAg
ICAgICAgICAgICAgICBVTlRJTCB+aXNEb3duO1xwYXINCj4gICAgICAgICAgICAgICAgICBJRiBp
bnNpZGUgVEhFTiAgICAoKiBtb3VzZSB3YXMgcmVsZWFzZWQgaW5zaWRlIHRoZVxwYXINCj4gY29u
dHJvbCAqKVxwYXINCj4gICAgICAgICAgICAgICAgICAgICAgZi5NYXJrUmVjdCgwLCAwLCB3LCBo
LCBQb3J0cy5maWxsLCBQb3J0cy5pbnZlcnQsXHBhcg0KPiBQb3J0cy5oaWRlKTtccGFyDQo+ICAg
ICAgICAgICAgICAgICAgICAgIElGIHYubGluayAjICIiIFRIRU5ccGFyDQo+ICAgICAgICAgICAg
ICAgICAgICAgICAgICBEaWFsb2cuQ2FsbCh2LmxpbmssICIiLCByZXMpICAgICgqIGludGVycHJl
dCBhbmRccGFyDQo+ICAgIGV4ZWN1dGUgdGhlIHN0cmluZyBpbiB2LmxpbmsgKilccGFyDQo+ICAg
ICAgICAgICAgICAgICAgICAgIEVORFxwYXINCj4gICAgICAgICAgICAgICAgICBFTkRccGFyDQo+
ICAgICAgICAgICAgICBFTFNFICAgICgqIGlnbm9yZSBvdGhlciBtZXNzYWdlcyAqKVxwYXINCj4g
ICAgICAgICAgICAgIEVORFxwYXINCj4gICAgICAgICAgRU5EIEhhbmRsZUN0cmxNc2c7XHBhcg0K
PlxwYXINCj4gICAgICAtRG91ZyBEYW5mb3J0aFxwYXINCj5ccGFyDQo+XHBhcg0KPiAgLS0tLSBU
byB1bnN1YnNjcmliZSwgc2VuZCBhIG1lc3NhZ2Ugd2l0aCBib2R5ICJTSUdOT0ZGIEJMQUNLQk9Y
IiB0b1xwYXINCj4gTElTVFNFUlZATElTVFMuT0JFUk9OLkNIXHBhcg0KXHBhcg0KXHBhcg0KLS0t
LVxwYXINClRvIHVuc3Vic2NyaWJlLCBzZW5kIGEgbWVzc2FnZSB3aXRoIGJvZHkgIlNJR05PRkYg
QkxBQ0tCT1giIHRvIExJU1RTRVJWQExJU1RTLk99fQC7KLkYIHBvAJA9Qgk
----boundary-LibPST-iamunique-1166822125_-_---
Received on Sun Jul 24 2011 - 06:57:08 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:12 UTC