I can't say that I've read all the code involved, but with what I know of both of pd externals (somewhat, but I'm no expert) and programming in TCL (pushing on 30 years), the way I'd do this in terms of architecture would be too have most of the work being done in TCL, and only communicate the data back to pd at important save points - at least for pure rendering work. Obviously audio parameters need to be more tightly coupled, even in edit mode. 

My point being, something like a widget resize most likely gets handled entirely on the TCL side. Certainly a lot of it *must* be handled in TCL, so you're really going to have to work it from that end to get to a good answer. PD really only knows what the TCL code tells it. 

Just my $0.02 worth, but I have run into similar issues when I've wanted to make gui things happen. 
Show quoted text


On Fri, 20 Dec 2024, 21:25 Alexandre Torres Porres, <porres@gmail.com> wrote:
I spoke too soon...

What I described works great for clicking while in run mode, and I needed that for some cases indeed. On the other hand, something resizing requires "edit mode" and things don't work like that in this case :) w_clickfn is just for run mode... but I know that objects in Pd like comment and atom boxes are aware of where you're hovering the mouse in edit mode and this is my next step in my investigation journey...

Em sex., 20 de dez. de 2024 às 18:09, Alexandre Torres Porres <porres@gmail.com> escreveu:
Em sex., 20 de dez. de 2024 às 14:26, Alexandre Torres Porres <porres@gmail.com> escreveu:
I see hcs/cursor is able to change and override the cursor. Will have a look at it...

The [cursor] object was a good way for me to investigate and find a solution, but it wasn't a solution in itself. It does change/overwrite the default cursors for Pd, but this strategy wasn't really working for me.

For the record, here is my finding: you can simply and easily change the cursor of a clickable GUI object by doing something like


    pdgui_vmess(0, "^r rs", x->x_cv, "configure", "-cursor", "pirate");


in your "w_clickfn" function, where "x_cv" is the current canvas. By doing the above in my [knob] object, I get a cute pirate whenever I hover the mouse on top of it. As soon as the mouse button goes out of the knob area it restores to "normal" and it works as expected when hovering over a "bang" object or something. I wasn't expecting nothing this easy :)

With more sophistication, I think I can specify different cursors by checking the area that the mouse is hovering on, like being able to use a double horizontal arrow to resize the object. In Cyclone there was a much more complicated structure to do something like this for the old Scope~ object. We improved some things but the same structure was there and it involved creating a new "window" widget and... whatever... too complicated, I think I can simplify this much more now and will do the same for my ELSE objects. I will report back if I don't succeed or something.

As for the 'edit mode' status awareness, I have my old solution and haven't found any better new solution and I might open a feature request soon proposing an "edit" message (much like the "zoom" message) to send to objects. If you think I shouldn't bother with that suggestion for some reason, let me know.

cheers

Hence, Pd has hardcoded 



 

Em qui., 19 de dez. de 2024 às 22:38, Alexandre Torres Porres <porres@gmail.com> escreveu:


Em qui., 19 de dez. de 2024 às 03:02, Alexandre Torres Porres <porres@gmail.com> escreveu:
I'm yet to better understand how setting cursor works, and I'm also thinking how to expanding this to iemguis, so they can also be resized in edit mode...

Ok, I see now this is taken care in canvas_doclick, which can set the cursor to "resize" in some cases. Things seem to be clearer now to me. 

But I also see now that it's all quite hard coded into Pd and impossible to expand it to externals. A GUI external could benefit from setting another cursor, such as "bottom_side" for a custom dropmenu button, or "plus" to tell you that you can add a segment into an envelope generator, etc.

Using the canvas_setcursor function into a w_clickfn call doesn't work to override the cursor. I can't think of a simple solution like I did by suggesting a new "edit" message in my last email. Nonetheless, I think this would be a nice feature that it's worth discussing.

cheers


 ---
pd-dev@lists.iem.at - the Pd developers' mailinglist
https://lists.iem.at/hyperkitty/list/pd-dev@lists.iem.at/message/T24UL3LJQKX44UPBQ6WCGOOHR2EI7HOU/