using a window while it doesnt have focus

I want to write to the text area of a window without showing it/making it active
ie
in window1 I have the code

window2.mymethodtoaddtext(“hello”)

If I use this from window 1 then window 2 gets focus.
Is there anyway to alter the text on a second window without activating it and giving it focus?
Thanks
Hamish

I’m still learning this language but every time you send something to the other window
can do something like:

// Window1
window2.mymethodtoaddtext("hello")
window1.setfocus // <-

Rui

Here http://documentation.xojo.com/index.php/Window.Visible

My guess is that you have ImplicitInstance turned on for Window2, and that Window2 has not yet been created? Thus, when you hit this line:

window2.mymethodtoaddtext("hello")

You are both creating window2 (which will naturally show it and activate it) and then calling mymethodtoadd text.

If not, then clearly something is happening in mymethodtoaddtext() to call Window2.Show.

Unfortunately, updating a TextArea on a window that isn’t yet visible, will indeed instantiate it and make it visible (and therefore its window). Referencing any item associated with Window2 will do this.

There’s a couple of ways you could tackle this problem but here’s an idea to get you started: use a Boolean flag which you check in TextArea.Open - the flag is set when you’re updating the text using your method. If the flag is True, you can then ensure the Window doesn’t change its Visible status (see Edgard’s link above)

Thanks Gavin, Thats a nice idea. Just tried using visible as Edgard suggested and that works well.