Looking in g_canvas.c, canvas can take a "click" message followed by 5 floats. The arguments are "t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt" but it none of those are used, at least by the following function:
static void canvas_click(t_canvas *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt) { canvas_vis(x, 1); }
It seems to only make the canvas visible, so try sending "click 0 0 0 0 0" to a named canvas...
On Jul 28, 2017, at 6:32 PM, pd-list-request@lists.iem.at wrote:
From: Roman Haefeli <reduzent@gmail.com mailto:reduzent@gmail.com> Subject: [PD] how to emulate mouse left-click to canvas? Date: July 28, 2017 at 4:55:26 PM GMT+2 To: Pd-List <pd-list@lists.iem.at mailto:pd-list@lists.iem.at>
Hey all
Is it still possible in Pd to send a message to canvas in order to emulate a mouse click? Some documents[1] and patches[2] on the Pure Data wiki suggest it was possible with earlier versions of Pd, but I can't get the examples to work with current Pd.
My aim is to make a symbolatom ready for text input without clicking it first.
Roman
Dan Wilcox @danomatika http://twitter.com/danomatika danomatika.com http://danomatika.com/ robotcowboy.com http://robotcowboy.com/
On Fre, 2017-07-28 at 19:46 +0200, Dan Wilcox wrote:
Looking in g_canvas.c, canvas can take a "click" message followed by 5 floats. The arguments are "t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt" but it none of those are used, at least by the following function:
static void canvas_click(t_canvas *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt) { canvas_vis(x, 1); }
It seems to only make the canvas visible, so try sending "click 0 0 0 0 0" to a named canvas...
Yeah, I couldn't figure out what this function is useful for and stopped digging further. But reading it made me confident that 'click' might doesn't do what I want. In the meantime, Ingo mentioned 'mouse'. I guess the corresponding code is found in g_editor.c:
void canvas_mouse(t_canvas *x, t_floatarg xpos, t_floatarg ypos, t_floatarg which, t_floatarg mod) { canvas_doclick(x, xpos, ypos, which, mod, 1); }
Roman
On Jul 28, 2017, at 6:32 PM, pd-list-request@lists.iem.at wrote:
From: Roman Haefeli reduzent@gmail.com Subject: [PD] how to emulate mouse left-click to canvas? Date: July 28, 2017 at 4:55:26 PM GMT+2 To: Pd-List pd-list@lists.iem.at
Hey all
Is it still possible in Pd to send a message to canvas in order to emulate a mouse click? Some documents[1] and patches[2] on the Pure Data wiki suggest it was possible with earlier versions of Pd, but I can't get the examples to work with current Pd.
My aim is to make a symbolatom ready for text input without clicking it first.
Roman
Dan Wilcox @danomatika danomatika.com robotcowboy.com
I don't think that does it as g_editor.c looks like the underlying logic for editing a patch (add, remove, move, etc) and doesn't forward the mouse events to the objects themselves.
On Jul 29, 2017, at 1:04 AM, Roman Haefeli reduzent@gmail.com wrote:
Yeah, I couldn't figure out what this function is useful for and stopped digging further. But reading it made me confident that 'click' might doesn't do what I want. In the meantime, Ingo mentioned 'mouse'. I guess the corresponding code is found in g_editor.c:
void canvas_mouse(t_canvas *x, t_floatarg xpos, t_floatarg ypos, t_floatarg which, t_floatarg mod) { canvas_doclick(x, xpos, ypos, which, mod, 1); }
Roman
Dan Wilcox @danomatika http://twitter.com/danomatika danomatika.com http://danomatika.com/ robotcowboy.com http://robotcowboy.com/
Here is a working example patch.
best wishes, ingo
On 29/07/17 02:00, Dan Wilcox wrote:
I don't think that does it as g_editor.c looks like the underlying logic for editing a patch (add, remove, move, etc) and doesn't forward the mouse events to the objects themselves.
On Jul 29, 2017, at 1:04 AM, Roman Haefeli <reduzent@gmail.com mailto:reduzent@gmail.com> wrote:
Yeah, I couldn't figure out what this function is useful for and stopped digging further. But reading it made me confident that 'click' might doesn't do what I want. In the meantime, Ingo mentioned 'mouse'. I guess the corresponding code is found in g_editor.c:
void canvas_mouse(t_canvas *x, t_floatarg xpos, t_floatarg ypos, t_floatarg which, t_floatarg mod) { canvas_doclick(x, xpos, ypos, which, mod, 1); }
Roman
Dan Wilcox @danomatika http://twitter.com/danomatika danomatika.com http://danomatika.com robotcowboy.com http://robotcowboy.com
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
here's some more details:
[mouse ...( and the corresponding [mouseup ...( are the mouse events that are sent to a canvas. BTW, you can use [iemguts/receivecanvas] -> [print] to check out all the messages the canvas receives.
[mouse ...( needs four arguments: xpos, ypos, button, key modifier. button is 1 for a leftclick and 3 for a rightlick (at least on Windows). key is 0 for no modifier pressed, 1 for SHIFT and 2 for CTRL. so as already explained, a leftclick message would be [mouse <x> <y> 1 0(
[mouseup ...( needs three arguments: xpos, ypos, button.
mouse events are processed by the editor in the function canvas_doclick (g_editor.c). it checks which object you've clicked on *) and calls the appropiate callback function in the classes's widget behaviour - which happens to be text_click (g_text.c) - which finally sends a "click" message to the object **). the click message takes 5 arguments: x, y, shift, alt, double click.
@Roman: you can send [click 0 0 0 0 0( directly to your symbol atom box and it will be ready for input (if the canvas is in focus). this way you don't have to care about the actual position.
some confusion arises from the fact that the canvas class also registers a 'click' method. but this is *not* the mouse event but the actual click event. the only thing it does is 'vis 1'.
Christof
*) there's one thing I've always found a bit odd in Pd: for mouse events the linked list of gobjects is traversed from the beginning (i.e. in the order of their creation), terminating when a click was successful. the consequence is that for overlapping sections of GUI elements, the backmost object gets the 'click' message. try to overlap two bang objects, click on them and you see what I mean.
**) actually, for gatoms text_click() directly calls gatom_click(), circumventing the messaging system. the 'click' message is nevertheless registered in the gatom class.
Gesendet: Samstag, 29. Juli 2017 um 02:00 Uhr Von: "Dan Wilcox" danomatika@gmail.com An: "Roman Haefeli" reduzent@gmail.com Cc: Pd-List pd-list@lists.iem.at Betreff: Re: [PD] how to emulate mouse left-click to canvas?
I don't think that does it as g_editor.c looks like the underlying logic for editing a patch (add, remove, move, etc) and doesn't forward the mouse events to the objects themselves.
On Jul 29, 2017, at 1:04 AM, Roman Haefeli <reduzent@gmail.com[mailto:reduzent@gmail.com]> wrote: Yeah, I couldn't figure out what this function is useful for and stopped digging further. But reading it made me confident that 'click' might doesn't do what I want. In the meantime, Ingo mentioned 'mouse'. I guess the corresponding code is found in g_editor.c:
void canvas_mouse(t_canvas *x, t_floatarg xpos, t_floatarg ypos, t_floatarg which, t_floatarg mod) { canvas_doclick(x, xpos, ypos, which, mod, 1); }
Roman
Dan Wilcox @danomatika[http://twitter.com/danomatika] danomatika.com[http://danomatika.com] robotcowboy.com[http://robotcowboy.com] _______________________________________________ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list%5Bhttps://lists.puredata.info/l...]
the click message takes 5 arguments: x, y, shift, alt, double click.
sorry, it's x, y, shift, ctrl, alt. mixed it up with text_click()
Gesendet: Samstag, 29. Juli 2017 um 12:30 Uhr Von: "Christof Ressi" christof.ressi@gmx.at An: "Roman Haefeli" reduzent@gmail.com Cc: Pd-List pd-list@lists.iem.at Betreff: Re: [PD] how to emulate mouse left-click to canvas?
here's some more details:
[mouse ...( and the corresponding [mouseup ...( are the mouse events that are sent to a canvas. BTW, you can use [iemguts/receivecanvas] -> [print] to check out all the messages the canvas receives.
[mouse ...( needs four arguments: xpos, ypos, button, key modifier. button is 1 for a leftclick and 3 for a rightlick (at least on Windows). key is 0 for no modifier pressed, 1 for SHIFT and 2 for CTRL. so as already explained, a leftclick message would be [mouse <x> <y> 1 0(
[mouseup ...( needs three arguments: xpos, ypos, button.
mouse events are processed by the editor in the function canvas_doclick (g_editor.c). it checks which object you've clicked on *) and calls the appropiate callback function in the classes's widget behaviour - which happens to be text_click (g_text.c) - which finally sends a "click" message to the object **). the click message takes 5 arguments: x, y, shift, alt, double click.
@Roman: you can send [click 0 0 0 0 0( directly to your symbol atom box and it will be ready for input (if the canvas is in focus). this way you don't have to care about the actual position.
some confusion arises from the fact that the canvas class also registers a 'click' method. but this is *not* the mouse event but the actual click event. the only thing it does is 'vis 1'.
Christof
*) there's one thing I've always found a bit odd in Pd: for mouse events the linked list of gobjects is traversed from the beginning (i.e. in the order of their creation), terminating when a click was successful. the consequence is that for overlapping sections of GUI elements, the backmost object gets the 'click' message. try to overlap two bang objects, click on them and you see what I mean.
**) actually, for gatoms text_click() directly calls gatom_click(), circumventing the messaging system. the 'click' message is nevertheless registered in the gatom class.
Gesendet: Samstag, 29. Juli 2017 um 02:00 Uhr Von: "Dan Wilcox" danomatika@gmail.com An: "Roman Haefeli" reduzent@gmail.com Cc: Pd-List pd-list@lists.iem.at Betreff: Re: [PD] how to emulate mouse left-click to canvas?
I don't think that does it as g_editor.c looks like the underlying logic for editing a patch (add, remove, move, etc) and doesn't forward the mouse events to the objects themselves.
On Jul 29, 2017, at 1:04 AM, Roman Haefeli <reduzent@gmail.com[mailto:reduzent@gmail.com]> wrote: Yeah, I couldn't figure out what this function is useful for and stopped digging further. But reading it made me confident that 'click' might doesn't do what I want. In the meantime, Ingo mentioned 'mouse'. I guess the corresponding code is found in g_editor.c:
void canvas_mouse(t_canvas *x, t_floatarg xpos, t_floatarg ypos, t_floatarg which, t_floatarg mod) { canvas_doclick(x, xpos, ypos, which, mod, 1); }
Roman
Dan Wilcox @danomatika[http://twitter.com/danomatika] danomatika.com[http://danomatika.com] robotcowboy.com[http://robotcowboy.com] _______________________________________________ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list%5Bhttps://lists.puredata.info/l...]
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list