textedit defocus (and hi! i'm back!)

mrjester's icon

hi everyone

good to see familiar faces. i'm back to max after too many years of doing other things. Wow, Max5 is all bulbous and pretty and stuff.

I have a question / bug report regarding textedit.

I am using the old old old trick, cadged from some smart person on this list, to defocus a textedit object upon entry of text (either on return or tab), which is to use scripting to create a number object, select it (giving it focus), and then delete it. I.e., I trigger the following message to a thispatcher:
[script new glxlxlx number 100 100 35 9 0 0 0 3, script send glxlxlx select, script delete glxlxlx]

This largely works great (although if there is a more "modern" way of defocusing a textedit, I'd love to know about it).

BUT, here is my problem: If I defocus a textedit in this way, and then switch to another application, and then switch back to Max, the focus will be on my textedit again. The same is not true if I just click outside the textedit to defocus it. Example patch attached. Max 5.0.3, OS X 10.4.11.

thanks
-j welter

ps - is there truly no way to get an email version of this list anymore? sadness......

pdelges's icon
Stephen Lee's icon

You can also subscribe to the Atom feed. I highly recommend using NetNewsWire for feeds since it can be set to automatically hide messages once they are read, and because it is keyboard shortcut friendly; e.g., you can easily go to the thread by pressing the right arrow key.

> Subscribe to maxmsp@cycling74.com mailing list
> and then you can just get every posting as an email and respond through email.

mrjester's icon

Quote: RabidRaja wrote on Sat, 30 August 2008 12:20
----------------------------------------------------
> Unless i misunderstood your latter question(and I probably did), you can go to the top of the Max/MSP forum list or the Jitter forum list or any other forum list of threads and click the link which reads:
> Subscribe to maxmsp@cycling74.com mailing list
> and then you can just get every posting as an email and respond through email.

Aha, thanks. Sorted.

Wetterberg's icon

Jer Welter skrev:
> This largely works great (although if there is a more "modern" way of defocusing a textedit, I'd love to know about it).
>
"enter Outputs the current text and takes the editing focus away from
the object. " - as far as I can tell this... works.
> BUT, here is my problem: If I defocus a textedit in this way, and then switch to another application, and then switch back to Max, the focus will be on my textedit again. The same is not true if I just click outside the textedit to defocus it. Example patch attached. Max 5.0.3, OS X 10.4.11.
I can reproduce that. It does appear to be a bug or "shortcoming", since
the function is supposed to specifically
"defocus", and not "defocus until window is deselected then selected".

Andreas

mrjester's icon

Aha, thanks to Andreas's post, on further inspection, I realize that in Max 5, the scripting defocus hack is no longer necessary - hitting enter in a textedit now clears the focus automatically (the patch I was working on originated in Max 4.x, where the scripting trick was necessary afaik).

But, the bug report still stands. If you hit enter in a textedit, thus clearing focus, and then you switch to another window and then back into the window containing the textedit, focus will have returned to the textedit. This happens regardless of whether the scripting defocus hack is used or not.

I can also now confirm this behavior on Windows as well as Mac, and be more specific about the behavior: the refocusing happens when you switch to any other other window - even another Max window - not just when you switch to another application.

Steps to reproduce:

1. Instantiate a textedit object.
2. Get info on the textedit and make sure "Return enters text" is checked.
3. Type something in the textedit, and then hit enter. The textedit will defocus.
4. Switch to any other window.
5. Switch back to the window containing your textedit. The focus will be back on the textedit. (Cursor insertion point will be at the start of the text in the textedit).

Jer

Ben Bracken's icon

I can see what you are talking about and i'll see if it is a bug or a documentation error. In the meantime, here is a workaround:

Max Patch
Copy patch and select New From Clipboard in Max.

-Ben

Stefan Tiedje's icon

Ben Bracken schrieb:
> I can see what you are talking about and i'll see if it is a bug or a
> documentation error. In the meantime, here is a workaround:

Not really a workaround, as then the number box is selected. Usually you
need that feature to get back a key object which is inactive while any
key receiving focus is on focus...

I would log this a s abug, and I'd request a function to the key object,
to be able to take the focus. Then this old akward hack would not be
necessary anymore.
Another option would be a specific defocus object. Any message to it
would defocus...

Yes this is a request... ;-)

Stefan

--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com

mrjester's icon

Quote: Stefan Tiedje wrote on Tue, 16 September 2008 01:16
----------------------------------------------------

> Not really a workaround, as then the number box is selected.
> Usually you need that feature to get back a key object which
> is inactive while any key receiving focus is on focus...

Yes. In fact, the old scripting create-numbox-give-it-focus-and-then-delete defocus technique works just fine, but in Max5 it seems to be no longer necessary - even without it, if the textedit is set to "return enters text" the textedit will defocus when you hit enter.

But, the defocus bug I'm talking about still happens: if you switch to another window, and switch back, the textedit has the focus again.

mrjester's icon

Ha, realized I already said all that earlier in the thread. The point is, however, the workaround that Ben posted is not a workaround. In his patch, the reason the textedit does not refocus is because the numbox has the focus - which defeats the whole purpose of defocusing. The workaround is basically the same as the old scripting defocus trick, but if you delete the numbox, the textedit will refocus when you switch windows.

Ben Bracken's icon

The textedit refocusing issue when leaving the window and returning has been fixed for the next release.

-Ben

mrjester's icon

huzzah - thanks for the quick fix!

jvkr's icon

Quote: ben@cycling74.com wrote on Fri, 19 September 2008 18:06
----------------------------------------------------
> The textedit refocusing issue when leaving the window and returning has been fixed for the next release.
>
> -Ben
>
>
----------------------------------------------------

There's another issue, which is that once in a standalone, the select message won't work altogether. Has that been fixed (by chance) with the latest repair? Can't wait for the new textedit.

cheers

_
johan

Ben Bracken's icon

Thanks for pointing out the standalone issue, we will check it out.

-Ben

domino's icon

hello All - it seems that the [textedit] 'select' message not working in standalones is really causing problems with an immediate deadline. if there are any ideas about workaround or alternates to using [textedit] that will survive the conversion to standalone application.

thanks for any help.

jvkr's icon

Yeah, I have a deadline too, somewhere in a month. Who knows if we'll see max 5.0.6 in time. Going trough some options, I came up with below.

_
johan

Max Patch
Copy patch and select New From Clipboard in Max.

ygreq's icon

Hey jvkr!

I was kinda stuck with the whole deal about writing and editing text. And you gave me a brilliant idea! ,!Thank you so much for that! I just wanted to display on the screen something someone types so I just used [comment] for that.

So I devised something really nice! It also allows you to delete letters you type!

OBS:
If you press enter, the whole text will be deleted
If you press Backspace, you will delete letter by letter

So.. everyone, please enjoy!!

(It might be a bit buggy because I just finished it! ;)

3097.typingusingcomment.maxpat
Max Patch
ygreq's icon

Well, it was buggy. :)

here is a better version.

3098.typingusingcommentv2.maxpat
Max Patch