dragging object fun


    Sep 14 2020 | 2:14 am
    See patch below. I'm trying to allow a user to visually drag a cell from a jit.cellblock object, "onto" another object (a panel), and to turn on that panel's border attribute.
    I have 2 cellblocks and 3 panels in the patch, and dragging from cellblock #1 should only toggle the border of panels #1 and 2 when over them, but not of panel #3. And dragging from cellblock #2 should only toggle the border of panel #3 when over it, but not of #1 and #2.
    As you can see in the patch, I've got the dragging part done, not perfect but good enough for now. Wondering how I should highlight the panels when over them though. I could obviously brute force it, but this is just a test patch of something that will be more complicated moving forward - ideally I'd like to be able to generalize things so that I can specify "highlight objects X or Y when dragging from object A onto them."
    Would Javascript be the best solution for this, and if so, any pointers?

    • Sep 14 2020 | 9:22 am
      panels had ignoreclick flag set, which at least in Max 6 excludes them from hover reporting. Changing that, and simple switch that uses name of mouse clicked object and mouse released object does the rest
      I did not touch the rest of the patch. I would prefer this one though :
    • Sep 14 2020 | 9:49 am
      I forgot the panel highlighting - that should be easy enough, now that hover reports them. Change brgb when over it, change back when mouse leaves them.
    • Sep 14 2020 | 11:21 am
      Thanks @Source Audio! You always have a way of finding good solutions for my posts! :-)
      And yes - I was being an idiot and forgot to adjust ignoreclick on all my panels (they were copied from another patch) - that obviously helps with the hover-ing! I also see what you did in your adjusted version, with the delay added in. That was also on my to-do list (why I said my original patch was not perfect) - I want to try and avoid any highlighted red box from showing if the user just clicks a cell, and does not drag it. Your version still does this, even if I increase the delay amount - will work on that some later, not critical for now.
      I'll probably convert your additions into abstractions that I can feed the object names into, so that I can generalize things as I indicated above.
      Thanks again!
    • Sep 14 2020 | 11:32 am
      You can change that red box appearing simply watching mouse position, and alowing red box to show only when mouse is clicked and from that point mouse position changed ...
      while trying this, I realised that while mouse is down hover object does not report . That makes highlighting the panels when one drags over a bit more complicated. One would have to split mouse coordinates and use that instead in oposite way : only when mouse is in set range and held down, panel gets highlighted. Now one needs to distinguish between patching and presentation mode which seems not possible using any messages or scripting. well if all were that easy where would be the fun to get things work ?
    • Sep 14 2020 | 1:23 pm
      Haha, yeah, the joy of Max'ing! Appreciate your help once again.