Getting data from a window without opening

Hello,
I created a separate window called “WSETUP” and i put there all the checkbox, TextField, etc with the preferences.
now, the problem i have is when i open the main window (different than WSETUP), and want to just get a value of an object in the WSETUP (like a checkbox for example), then WSETUP opens…

is any efficient way to keep things separated (like in windows) and share data between them without opening?

Thanks!!

Hi @Javier_Cortes

I think that the best approach is to use separate classes (that is, specific classes) to store the values the user may set in a Window… as it is the case with the WSETUP window. Then, instances from that DATA class can be assigned to a global property you can read or store values into without needing to access directly the VIEW layer that is designed to represent these and interact with the user.

I mean, take a MVC (model/view/controller) approach instead of accesing view controls always it is possible.

Gracias Javier!
I will explore that. I’m just seeing my software growing fast and wanted to keep things separate inside xojo and I like for the UI, to have different windows and windows sizes depending what they need to see.
i will explore that way you mention.
Thanks!

Also see Examples>Sample Applications>XojoNotes>XojoNotesDesktop

Why don’t you just use shared properties in that window?

Thank you @JulianS and @RomanV
RomanV, I also could use a shared property, yes. But a i need access to list values as well… passing the list as string every time it changes… maybe?

I think I found a solution that works pretty simple and not need too much coding or variables:
I open all the windows as hide. so everything is accesible using window1. window2. etc. then, i call each using .show via buttons i have as menu. i can see the desired window, and then when i close it, instead of closing i just hide it again.
so, they are all open all the time, its just the user dont see them until one window is needed.
not sure if it is pretty, but… so far it works and less coding/variables.
if you feel i’m an ignorant feel free to tell me jajaja… just learning ways.

I’d actually create a dictionary holding Wsetup data. That dictionary could be a shared property of the window or not. But that would separate the view from the data layer as suggested.

Many people do not like ‘global’ variables, but it will solve all your problems.
So at the risk of a flame war: I suggest you simply use a set of ‘global variables’

How:?

Add a module to your project
Add the properties you wish to interrogate there, and set their scope to be public.

You can read them from any window or module or class
You can use them to set up a window in the window’s open or activate events

And you can save and load these properties as preference settings when your app opens or closes.

RomanV’s suggestion of creating a dictionary or a global class is a similar solution.

@Jeff_Tullin , I love global variables.
@RomanV I love the dictionary idea. i think i will try that avenue. i forgot that i could combine data in the dictionary right? Also folderitems in the dictionary, right? thanks for the advices!

i think your problem is this implicit instance behavior from window.
if you use WSETUP.MyProperty it opens first
i remember if you use
var w as new WSETUP
if w.MyProperty then
it does not open until u use w.Show
you can store this w object elsewhere.

this implicit instance is only one window and the other method open each time a new one.

1 Like

Thank you Markus!