Skip to content
Snippets Groups Projects
Commit 88955836 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

fake mouseup message on window blur, move a comment that was in the wrong place

parent ce48a4ca
No related branches found
No related tags found
No related merge requests found
...@@ -106,6 +106,11 @@ function nw_window_focus_callback() { ...@@ -106,6 +106,11 @@ function nw_window_focus_callback() {
} }
} }
function nw_window_blur_callback(name) {
// Fake a mouseup event
pdgui.pdsend(name, "mouseup_fake");
}
// These three functions need to be inside canvas_events closure // These three functions need to be inside canvas_events closure
function canvas_find_whole_word(elem) { function canvas_find_whole_word(elem) {
canvas_events.match_words(elem.checked); canvas_events.match_words(elem.checked);
...@@ -416,18 +421,11 @@ var canvas_events = (function() { ...@@ -416,18 +421,11 @@ var canvas_events = (function() {
}, },
text_mousedown: function(evt) { text_mousedown: function(evt) {
if (textbox() !== evt.target && !target_is_scrollbar(evt)) { if (textbox() !== evt.target && !target_is_scrollbar(evt)) {
// Yes: I _really_ want .innerText and NOT .textContent
// here. I want those newlines: although that isn't
// standard in Pd-Vanilla, Pd-l2ork uses and preserves
// them inside comments
utils.create_obj(); utils.create_obj();
//var fudi_msg = text_to_fudi(textbox().innerText);
//pdgui.pdsend(name, "createobj", fudi_msg);
//pdgui.post("formatted content is " + fudi_msg);
// send a mousedown and mouseup event to Pd to instantiate // send a mousedown and mouseup event to Pd to instantiate
// the object // the object
events.mousedown(evt); events.mousedown(evt);
events.mouseup(evt); //events.mouseup(evt);
canvas_events.normal(); canvas_events.normal();
} }
evt.stopPropagation(); evt.stopPropagation();
...@@ -559,6 +557,10 @@ var canvas_events = (function() { ...@@ -559,6 +557,10 @@ var canvas_events = (function() {
}, },
utils = { utils = {
create_obj: function() { create_obj: function() {
// Yes: I _really_ want .innerText and NOT .textContent
// here. I want those newlines: although that isn't
// standard in Pd-Vanilla, Pd-l2ork uses and preserves
// them inside comments
var fudi_msg = text_to_fudi(textbox().innerText), var fudi_msg = text_to_fudi(textbox().innerText),
fudi_array = string_to_array_of_chunks(fudi_msg), fudi_array = string_to_array_of_chunks(fudi_msg),
i; i;
...@@ -769,6 +771,9 @@ var canvas_events = (function() { ...@@ -769,6 +771,9 @@ var canvas_events = (function() {
gui.Window.get().on("focus", function() { gui.Window.get().on("focus", function() {
nw_window_focus_callback(); nw_window_focus_callback();
}); });
gui.Window.get().on("blur", function() {
nw_window_blur_callback(name);
});
// set minimum window size // set minimum window size
gui.Window.get().setMinimumSize(150, 100); gui.Window.get().setMinimumSize(150, 100);
......
...@@ -4741,6 +4741,15 @@ void canvas_mouseup(t_canvas *x, ...@@ -4741,6 +4741,15 @@ void canvas_mouseup(t_canvas *x,
(glob_shift + glob_ctrl*2 + glob_alt*4), 0); (glob_shift + glob_ctrl*2 + glob_alt*4), 0);
} }
/* Cheap hack to simulate mouseup at the last x/y coord. We use this in
the GUI in case the window gets a blur event before a mouseup */
void canvas_mouseup_fake(t_canvas *x)
{
if (x->gl_editor && x->gl_edit)
canvas_mouseup(x, x->gl_editor->e_xwas, x->gl_editor->e_ywas, 0);
}
/* This entire function is made superfluous in the GUI port-- we get middle- /* This entire function is made superfluous in the GUI port-- we get middle-
click pasting for free by default. */ click pasting for free by default. */
void canvas_mousedown_middle(t_canvas *x, t_floatarg xpos, t_floatarg ypos, void canvas_mousedown_middle(t_canvas *x, t_floatarg xpos, t_floatarg ypos,
...@@ -7459,6 +7468,8 @@ void g_editor_setup(void) ...@@ -7459,6 +7468,8 @@ void g_editor_setup(void)
A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL); A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
class_addmethod(canvas_class, (t_method)canvas_mouseup, gensym("mouseup"), class_addmethod(canvas_class, (t_method)canvas_mouseup, gensym("mouseup"),
A_FLOAT, A_FLOAT, A_FLOAT, A_NULL); A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
class_addmethod(canvas_class, (t_method)canvas_mouseup_fake,
gensym("mouseup_fake"), A_NULL);
class_addmethod(canvas_class, (t_method)canvas_mousedown_middle, gensym("mouse-2"), class_addmethod(canvas_class, (t_method)canvas_mousedown_middle, gensym("mouse-2"),
A_FLOAT, A_FLOAT, A_FLOAT, A_NULL); A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
class_addmethod(canvas_class, (t_method)canvas_key, gensym("key"), class_addmethod(canvas_class, (t_method)canvas_key, gensym("key"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment