[PD-dev] local canvas-only pd_bind

Dan Wilcox danomatika at gmail.com
Sun Mar 17 13:38:37 CET 2019

That's a similar concept to Cocoa's NSTrackingArea. It's basically a rectangle in a view that you attach which then receives mouse enter, leave, move, down, up, & drag events. You can update the position and size whenever.

https://developer.apple.com/documentation/appkit/nstrackingarea?language=objc <https://developer.apple.com/documentation/appkit/nstrackingarea?language=objc>

I could imagine something similar in Pd, say a [mousearea] object. Also, updating [cnv] with similar functionality would be useful. [mousearea] could be used for arbitrary areas for control interaction and drawing of other objects while [cnv] could be used to create simple graphical regions for things like piano keys. I know there have been different approaches in this area, so it might be helpful to take a look (DesireData, PurrData, etc).

I think this would complement a general, canvas wide set of [mouse] objects. I started by following the existing approach and split functionality into [mouse], [mouseup], and [mousemotion]. Another approach would be to use a single [mouse] object with a status symbol in addition to x & y.

> On Mar 17, 2019, at 12:15 PM, Chris McCormick <chris at mccormick.cx> wrote:
> Hi Dan,
> Thanks so much for looking at this.
> What I really want as an end-user is to be able to know "has this particular rectangle received mouse-down, mouse-motion, or mouse-up?"
> I think this would bring huge flexibility in allowing people to build complex user interfaces at the patch level. Things like ribbon controllers max/min selectors, click-and-hold buttons etc.
> Cheers,
> Chris.
> On 16/3/19 10:01 am, Dan Wilcox wrote:
>> Howdy all,
>> I played around a bit with forwarding canvas mouse click events to a [mouse] object. This works fine using a bind to a global "#mouse" symbol, however this means all objects receive events from all canvases.
>> How can I change this to be local canvas only, as in only [mouse] objects within the canvas receive the events? I was thinking to generate a symbol with the canvas id ala how [openpanel] and [savepanel] work:
>>     sprintf(buf, "d%lx", (t_int)x);
>>     x->x_s = gensym(buf);
>>     x->x_canvas = canvas_getcurrent();
>>     pd_bind(&x->x_obj.ob_pd, x->x_s)
>> However, this means the canvas mouse function would need to generate the equivalent symbol each time the event is called in order to check if anything is bound to it. This seems wasteful. I suppose I could add a cached symbol somewhere, maybe to the g_canvas instance struct, however I'd like avoid that.
>> --------
>> Dan Wilcox

Dan Wilcox
@danomatika <http://twitter.com/danomatika>
danomatika.com <http://danomatika.com/>
robotcowboy.com <http://robotcowboy.com/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20190317/85efb78f/attachment.html>

More information about the Pd-dev mailing list