Oddly basic question: Number box highlighting.

Jan 26, 2013 at 3:27am

Oddly basic question: Number box highlighting.

Is there any way to make the background of a number box (flonum too) highlight when you tab to it using the ‘select’ message? I’m having trouble thinking of a graceful (ie, less than two-three extra objects) way to handle it. AFAIK, the only thing that highlights is the triangle, which just isn’t enough of a visual notifier when you’re bouncing around a patch tabbing through parameters.

#66228
Jan 26, 2013 at 4:11am

Maybe have the number box bkgd be transparent, and have a panel behind it (or in front of it) that highlights?

#238380
Jan 26, 2013 at 7:15am

…or change the color of the numberbox´background by messages.

#238381
Jan 26, 2013 at 7:31am

Both ideas that I’d thought of, but that are somewhat cumbersome when you have large amounts of number boxes – when you add in the logic for telling when a box is highlighted or not, it starts to get ugly. Plus, neither of those methods would work if you just click on the number box to highlight it.

– Pasted Max Patch, click to expand. –

Would be how it works, but there’s a number of problems I have with it – the biggest being the rats nest of cables it ends up producing. Other issues are that there’s no way to know when the user deselects a box by clicking (thus highlighting none of the boxes) without also adding in a ubutton or similar covering the background of the whole patch. And, like I’d mentioned earlier, there’s apparently no way to tell if the user has selected a number box by clicking on it.

#238382
Jan 26, 2013 at 8:56pm

some more ideas…an interesting challenge :)

I don’t think there’s a way to tell if the user clicked outside a box except using the ubutton or [mousestate], but you can utilize [hover] for some more checking.

– Pasted Max Patch, click to expand. –
#238383
Jan 26, 2013 at 9:48pm

It might be nice to have “select hilights box” as a checkbox attribute for numbox and flonum. So it would do the same as mousing does (highlight the box) when you select it programmatically via tab or other means.

You could also have a third outlet which bangs when the numbox is clicked, so you don’t have to wait for an actual number output.

Updated example patch with some more features :)

– Pasted Max Patch, click to expand. –
#238384
Jan 27, 2013 at 1:15am

Seejay, those are both veeery interesting concepts – though problematic if I am using scripting names on things for pattr/autopattr purposes. The other problem with the second version is that it can affect named objects that are not number boxes (like toggles or [functions] or what have you).

However, I’m looking more into [hover] and it seems like the third outlet might be handy as well, to unhighlight when the mouse leaves the object.

Perhaps there’s a way with Javascript to check if an object with scripting name ‘blah’ is of class ‘flonum’? I’m not well versed enough in Max Java to know how to do that, though.

#238385
Jan 27, 2013 at 1:34am

Whoop, making some progressing on testing if the object hovered is a flonum! Sample incoming in a bit.

#238386
Jan 27, 2013 at 2:06am

Alright, not sure if javascript get copied with copy compressed:

– Pasted Max Patch, click to expand. –

Here’s the javascript code just in case:

function highlightnumbox(a)
{
var b = this.patcher.getnamed(a);
if (b.maxclass == “flonum” || b.maxclass == “number”)
{
b.message(“bgcolor”, “.5″, “.7″, “.7″)
}
}

function dehighlightnumbox(a)
{
var b = this.patcher.getnamed(a);
if (b.maxclass == “flonum” || b.maxclass == “number”)
{
b.message(“bgcolor”, “1″, “1″, “1″)
}
}

#238387
Jan 27, 2013 at 2:38am

Sounds cool, though I don’t see a problem with named objects and pattr, why would that be an issue? The names have to be unique, so there shouldn’t be any confusion there. I just named them “numbox[1]” etc, but they could be called “frank” or “bob”. The number index is handy so that when you duplicate it, it automatically increments the value in the brackets.

I guess [autopattr] might name things that would be problematic, so just name things manually I guess…

I like the javascript idea too, that will eliminate yet more cords! :)

#238388
Jan 27, 2013 at 3:43am

I just had a brief-ish look at your patch, it looked like it was doing something with the number in brackets (IE, numbox[1]). I’m thinking the javascript way is the ‘cleanest’ though – it doesn’t need any extra objects connected directly to the number boxes! Next step is to see if I can both make it Select the number box when you hover (shouldn’t be hard, just another message to send), and de-highlight when you tab away. Which I can probably do by having a message connected to the second outlet of the numberbox, which contains the name of the next number box in the chain – won’t even need to patch the number boxes together!

Hooray! (And thanks for the help!)

#238389

You must be logged in to reply to this topic.