Em qua., 6 de nov. de 2024 às 14:14, IOhannes m zmölnig <zmoelnig@iem.at> escreveu:
Getting the edit mode, should be easy enough:
<https://github.com/pure-data/pure-data/blob/c2d65103e5c068fa466260480b012ef03aed58a2/src/g_editor.c#L2254>

hi, by printing on this code I see this can give me  the edit status but not immediately when getting into edit mode. On the other hand, the comment box responds immediately to the edit status and shows the sidebar handle. This code does in fact listen to mouse events, so getting into edit mode via the keyboard shortcut is not enough, I have to move the mouse around and then I can see if it is in edit mode. Same is true for getting out of edit mode. 

My 'hacky' way is to listen to canvas messages, and it works great, see [else/canvas.edit]. But I do wonder if there's a better way.

By the way, I'm always bothered by the fact that the cursor does not automatically change to a hand when getting into edit mode, we do need to move the mouse so it can be aware. I wonder if it's because it uses this 'canvas_doclick' function. Nonetheless, when getting out of edit mode, it goes back to the arrow cursor just fine. I will open an issue about this, I hope there is a way to listen to the edit status and make this transition better.

I now also remember and realize that the canvas window does report if it's in edit mode or not with "(edit)", I will try and see if I can find how this works in the code.
 
But iirc, there's no proper way for an arbitrary object to receive mouse events while in edit mode.
Everything you mentioned is hardcoded in Pd's editor itself.

And the "widgetbehaviour" API is really a prime example of bad design (with respect to extendibility), so it's not easy to change it to make more objects do something class-specific in edit mode, without cluttering rather unrelated code (g_editor), or - possibly - resorting to even uglier hacks

I was just hoping to get the edit mode status really.

Other than that, I wanted to check how the comment box works and how all of it is coded on there. 

I am actually able to do these things. See else/note for instance, but I wanted to be able to understand how this is done in Pd, maybe there is a better strategy.

thanks