PDA

View Full Version : windowslist, subwindow and hasFocus.



earthworm3
April 13th, 2013, 11:35
Hello, i have a windowlist with multiple value and when i wheel up/down my mouse, all change value, not one :

function onWheel(notches)
local win = getWindows();
for k,v in pairs(win) do
if (hasFocus()) then
changevalues(v,notches);
end
end
end

The hasFocus function work on the windowlist but not on subwindow... Any idea ?

Ikael
April 13th, 2013, 11:44
Because subwindow is not a window, it's a container for window, see https://www.fantasygrounds.com/refdoc/subwindow.xcp

Could you provide little bit more code about what you want to achieve?

earthworm3
April 13th, 2013, 11:57
Into this windowlist i have buttons in many subwindow fields and i want to change their values, but only when i focus a subwindow field :


function changevalues(v,notches)
if (v) then
local button2 = v.getDatabaseNode().getChild("others12").getValue();
local button1 = v.getDatabaseNode().getChild("others11").getValue();
local total = 0;

if (notches >= 1) then
if (button1 == 0 and button2) then
v.getDatabaseNode().getChild("others11").setValue(1);
total = 1;
elseif (button1 == 1 and button2 == 0) then
v.getDatabaseNode().getChild("others12").setValue(1);
total = 2;
end
elseif (notches <= 0) then
if (button1 == 1 and button2 == 1) then
v.getDatabaseNode().getChild("others12").setValue(0);
total = 1;
elseif (button1 == 1 and button2 == 0) then
v.getDatabaseNode().getChild("others11").setValue(0);
total = 0;
end
end
end
end

EDIT : the problem is the hasFocus() function in post 1 ...

Trenloe
April 14th, 2013, 06:06
As Ikael says in post #2, hasFocus is a command for the windowlist control, not the controls within the window list: https://www.fantasygrounds.com/refdoc/windowlist.xcp#hasFocus

As you step through your windowinstance objects in the list, hasFocus will always return true because it is for the windowlist container control, not the individual objects within that control. Hence why using the mousewheel changes each line.

There does not appear to be a hasFocus command for the individual windowinstance objects in the windowlist.

earthworm3
April 14th, 2013, 12:28
ok thanks, so what can i do ?

Trenloe
April 14th, 2013, 15:16
ok thanks, so what can i do ?
Use individual controls that are not in a windowlist, then the onWheel eevent will be raised just for that control.

Look at the DotControl template in the nWoD ruleset to see how to do this.

earthworm3
April 14th, 2013, 17:10
thank you for your reply.

earthworm3
April 14th, 2013, 18:31
Thanks it's work.