cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Working with window_create and xui

pzorrilla
1-Newbie

Working with window_create and xui

Hello experts!

I've been working with window_create and xui, my goal is to develop a
new window where users can manipulate xml documents on Arbortext,
however I've faced a difficult. I was wondering if there's a way in
which I could identify the window which was created and when the user
try to create a new window, Arbortext could block the creation.
Currently I'm creating the window since a customized menu on my toolbar,
but every time user calls at this command a new window is created, I
don't know how can I manage this stuff. All that I need is to have
control over the creation of my window and identify if one has been
created so user can not create another one. Hope I've been clear with my
question and you could help me.

As always I really appreciate your support as your time,
Paulette
2 REPLIES 2

Hi Paulette--

One approach you could try is this:

1) use a global ACL variable to track the presence/absence of your singleton window, and set it to the window ID when you create the window
2) after the window is created, add a window_destroy callback to reset the global variable to -1.
3) in your menu item, add an "active" setting that checks the global variable, e.g. -active " $mypkg::win_exists==-1"

That way, as long as the custom window exists, the menu item for creating a new one will be disabled.

--Clay


Clay Helberg
Senior Consultant
TerraXML

Another option, assuming that the dialog is associated with a specific document - and, thus, you might want to have multiple instances, just not more than one per document - would be to store a mapping of document IDs to dialog IDs in a global array, and consult it before creating a new window.

global DIALOGS[];

function show_my_dialog(doc=current_doc()) {
if ($DIALOGS[doc] && window_valid($DIALOGS[doc])) {
# Dialog already exists
window_activate($DIALOGS[doc]);
return;
}
local dlg = … # create dialog
$DIALOGS[doc] = dlg;
}

Chris
Chris Nitchie
Oberon Technologies, Inc.
2640 Wildwood Trail
Saline, MI 48176
Top Tags