How to create a jsui object that works in both patch and presentation mode?

    Nov 24 2016 | 9:25 pm
    I am having trouble creating a jsui object that works correctly when the object has a different size in patch mode than in presentation mode.
    I am using relative coordinates and sketch.screentoworld(x,y) to get click points. However, it seems that sketch.screentoworld() always uses the patch rectangle for it's transformation and not the presentation rectangle. So when clicking on the corners in patch mode, you get correct -1. to 1. range for the corners of the object, but when switching to presentation mode, the range seems to be related to the size of the patching rect, and not the new presentation rect.
    How are we supposed to handle this situation?
    Note: This is reproducible with the C74 example mgraphics-hittest patch.

    • Nov 26 2016 | 10:18 pm
      I did report this shortcoming a few years ago. Only work-round is to use the same size for patch and presentation.
    • Nov 30 2016 | 6:13 pm
      my workaround: use a separate sketch for mouse input events. creation of that sketch in some init function:
      mysketch = new Sketch(box.rect[2] - box.rect[0], box.rect[3] - box.rect[1]);
      and in any function you use mouse positions, e.g. button down
      function onclick(x, y, button_down) { var w = mysketch.screentoworld(x, y); ... }
      for painting, i'm using the standard sketch