Forums > MaxMSP

Fix Width message?

June 4, 2014 | 1:41 am

Hi All,

Is there a message I can send to comment boxes that has the same effect as fix width?

I am changing the content of comment boxes dynamically in a patch and need them to resize relative to the content.

Thanks, as always for your help.

Nick

Max 6.07
Macbook Pro 13" (2010)


June 6, 2014 | 9:56 am

Bumpity bump.


June 6, 2014 | 10:10 am

The patching_rect attribute.

– Pasted Max Patch, click to expand. –

June 6, 2014 | 10:32 am

Thanks for your response Christopher.

Whilst your solution clearly allows for the patch-designer to fix the width of the comment box I’m seeking a way for the comment box to automatically fix width if content is updated whilst the patch is live.

For example, imagine the user triggers an event that updates a comment box with text of significantly shorter length than its previous content,there is now excess space in the comment box.

Here’s an example of the problem for clarity:

– Pasted Max Patch, click to expand. –
  • This reply was modified 3 months by  nick williams. Reason: Tweeked example patch to make sense

June 6, 2014 | 10:52 am

I thought you were asking how to change the size of an object with a message. (The matter of whether it’s done by hand or by automated process is a separate issue from how to do it at all.) I thought the solution would then be implicit. I suggest to check the length of the message, and adjust the width of the object commensurately. If the messages are all known in advance, you can even store in advance all the appropriate widths associated with the messages, and look them up when the messages are chosen.


June 6, 2014 | 11:04 am

Pre-Programming the length is an option, however, not ideal.

What object reports the length of a symbol? It doesn’t seem to be possible with [regexp], anyone have any ideas? Racking my brains (and feeling as though I’m missing the obvious)…

Thanks Christopher,

Nick


June 6, 2014 | 6:26 pm

I find that JavaScript is really handy for anything dealing with strings of characters. Download the attached super-simple .js file, save it somewhere in the Max file search path, and then try this patch.

– Pasted Max Patch, click to expand. –
Attachments:
  1. wordlength.js

June 7, 2014 | 7:46 am

That’s perfect Christopher! The javascript example will work once adapted. Auto-fixwidth here I come!

Thanks so much for your input and time.

All the best,

Nick


June 7, 2014 | 8:36 am

After all that, though, unless you’re generating messages on the fly, it seems to me to be more straightforward just to store the desired comment width along with the message, something like this.

– Pasted Max Patch, click to expand. –

June 7, 2014 | 8:44 am

Whilst you are right, I will be giving my patch to a third party. A function I am building in is the ability for the user to add their own text that will appear on screen at certain times. Therefore I cannot predict the length of the text they add and also do not want to burden the user with measuring text-length themselves. I’m trying to minimise the steps they have to take when they personalise their patch.

If it was just for my use, I would agree 100% with you and pre-programme the widths.

Cheers,

Nick


Viewing 10 posts - 1 through 10 (of 10 total)