PDA

View Full Version : Window/subwindows and combobox odd behavior



celestian
February 7th, 2019, 06:15
I am having some odd behavior with combobox within a subwindow.

In a Story window I've added a subwindow (author_header) above the typical "header" subwindow and attached the header to the bottom of the author_header. Within the author_header subwindow I've added 2 labels, a checkbox and a combobox.

When using the combobox that has a selection already (see animated gif below) the combobox opens but the view is slid down and the top of the combobox is pushed up where it's not visible. In the animation you can see that when I move the mouse up (when I go to the right side) to the author_header section and use mousewheel it will snap up to top and look normal.

Is there an event I can capture that I can then run "setScrollPosition(0,0)" on the subwindow and correct this when the combobox is opened? Or is there another way to deal with this?

https://i.imgur.com/003RMZq.gifv
https://i.imgur.com/003RMZq.gifv

The subwindow template and combobox template are nothing special but here they are:



<template name="note_author_header">
<subwindow>
<anchored>
<top offset="23" />
<left offset="15" />
<right offset="-15" />
</anchored>
<activate />
<fastinit />
</subwindow>
</template>

<template name="author_frameselect">
<combobox>
<script>
function onInit()
super.onInit();
addItems(AuthorManagerADND.aBlockFrames);
end
</script>
<anchored>
<top parent="rightanchor" offset="8" />
<left offset="45" />
<right offset="-90" />
</anchored>
<listdirection>down</listdirection>
<listmaxsize>8</listmaxsize>
</combobox>
</template>

Moon Wizard
February 7th, 2019, 06:54
It's because the combobox is actually an amalgation of controls, and the combobox creates a windowlist control above itself by default. Because your combo box is at the top of the window, the window is trying to re-layout to accommodate the extra controls.

If you specify a <listdirection>down</listdirection> tag for your template, the combobox should append the selection list below the string field.

Regards,
JPG

celestian
February 7th, 2019, 16:01
If you specify a <listdirection>down</listdirection> tag for your template, the combobox should append the selection list below the string field.


I do have listdirection set to down. Or do you mean somewhere else?



<template name="author_frameselect">
<combobox>
<script>
function onInit()
super.onInit();
addItems(AuthorManagerADND.aBlockFrames);
end
</script>
<anchored>
<top parent="rightanchor" offset="8" />
<left offset="45" />
<right offset="-90" />
</anchored>
<listdirection>down</listdirection>
<listmaxsize>8</listmaxsize>
</combobox>
</template>

Moon Wizard
February 7th, 2019, 17:40
Apologies, that's what I get for answering late, and making assumptions.

Looking at it again and knowing that the combobox is down; I'm going to guess that the combobox is within a subwindow which is dynamically sizing larger when the combobox list is created? If that's the case and the other controls are anchored to the subwindow, then they will be pushed down when the subwindow resizes.

It's a known limitation of the combobox limitation that it doesn't play nice within nested subwindows, because it is an amalgamation of controls and laid out as inidividual controls. If you have it nested, then it will either be clipped (if using fixed height subwindow) or will expand the subwindow (if using dynamic height subwindow). This is similar for child windows of a windowlist.

Regards,
JPG

celestian
February 7th, 2019, 17:57
Apologies, that's what I get for answering late, and making assumptions.

Looking at it again and knowing that the combobox is down; I'm going to guess that the combobox is within a subwindow which is dynamically sizing larger when the combobox list is created? If that's the case and the other controls are anchored to the subwindow, then they will be pushed down when the subwindow resizes.

It's a known limitation of the combobox limitation that it doesn't play nice within nested subwindows, because it is an amalgamation of controls and laid out as inidividual controls. If you have it nested, then it will either be clipped (if using fixed height subwindow) or will expand the subwindow (if using dynamic height subwindow). This is similar for child windows of a windowlist.

Regards,
JPG

Yup, it's stacked subwindows. I'll tinker with it a little more and see what I can maybe get working. If not, sounds like a cycler might be a better choice for this. If I limit the choices to a smaller list the drop box will be less necessary anyway.

celestian
February 7th, 2019, 23:37
Not the way I wanted to do it but this works.

(cycler). It took some tinkering to initialize the non-static data.
https://i.imgur.com/zpdj5nv.gifv

Here is the meat of it.


<template name="author_frameselect">
<button_stringcycler>
<script>
function onInit()
local sSelections = "";
for _, sItem in pairs(AuthorManagerADND.aBlockFrames) do
sSelections = sSelections .. sItem .. "|";
end
super.onInit();
super.initialize(sSelections, sSelections,DB.getValue(window.getDatabaseNode(),"ref_frame",AuthorManagerADND.aBlockFrames[1]));
super.updateDisplay();
end
</script>
<anchored width="80" height="15">
<top parent="rightanchor" offset="8" />
<left anchor="center" offset="-40" />
</anchored>
</button_stringcycler>
</template>