Thread: button_iedit - dosen't work
-
July 20th, 2022, 11:06 #1
button_iedit - dosen't work
I have a problem with button_iedit. Basically what happens to me is that it does not update (disappears or appears) when I lock the window.
If the window is locked when I open it, the button is not there, if it is not locked the button appears, but it does not change state when the lock changes with the window open.
I have compared my code with other codes I have found and it does not seem different to me. But it does not work. Also I don't see the button_idelete appear and disappear.
I've a doubt. Each code I see has a call like this --> element_list.update(bReadOnly);
But no update is present in element_list; should I implement it? And why other codes do not implement it?
Code:<windowclass name="reference_group"> <frame>recordsheet</frame> <placement> <size width="460" height="520" /> </placement> <sizelimits> <minimum width="460" height="520" /> <maximum width="460" height="1000" /> <dynamic /> </sizelimits> <minimize>minimized_reference</minimize> <tooltip field="name" /> <nodelete /> <playercontrol /> <sharable /> <script> function onLockChanged() if header.subwindow then header.subwindow.update(); end if main.subwindow then main.subwindow.update(); end local bReadOnly = WindowManager.getReadOnlyState(getDatabaseNode()); end </script> <sheetdata> <sub_record_header name="header"> <class>ref_group_header</class> </sub_record_header> <frame_record_content name="contentframe" /> <subwindow name="main"> <anchored to="contentframe" position="over" /> <class>ref_group_main</class> <activate /> </subwindow> <scrollbar_record> <target>main</target> </scrollbar_record> <resize_recordsheet /> <close_recordsheet /> </sheetdata> </windowclass> <windowclass name="ref_group_header"> <margins control="0,0,0,2" /> <script> function onInit() update(); end function update() local bReadOnly = WindowManager.getReadOnlyState(getDatabaseNode()); name.setReadOnly(bReadOnly); end </script> <sheetdata> <link_record_header> <class>reference_group</class> </link_record_header> <anchor_record_header_right /> <icon_record_locked /> <button_record_locked /> <string_record_name name="name"> <empty textres="library_recordtype_empty_group" /> </string_record_name> <label_reftype name="reftype"> <static textres="ref_type_group" /> </label_reftype> </sheetdata> </windowclass> <windowclass name="ref_group_main"> <margins control="0,0,0,2" /> <script> function onInit() update(); end function update() local bReadOnly = WindowManager.getReadOnlyState(getDatabaseNode()); element_list.update(bReadOnly); end function updateDropDown(sControl, sDropDown) if self[sControl].isReadOnly() then self[sDropDown].setVisible(false); else self[sDropDown].setVisible(true); end end </script> <sheetdata> <anchor_column name="columnanchor" /> <header_column name="element_header"> <static textres="library_recordtype_label_element"/> <center /> <script> function onInit() if Session.IsHost then setTooltipText(Interface.getString("tooltip_group_elements")); end end function onDrop(x, y, draginfo) window.element_list.onDrop(x, y, draginfo); end </script> </header_column> <button_iedit name="element_iedit"> <anchored to="element_header" position="righthigh" offset="-20,0" /> <target>element_list</target> </button_iedit> <list_column name="element_list"> <anchored> <top parent="columnanchor" anchor="bottom" relation="relative" offset="5" /> </anchored> <allowcreate merge="delete" /> <class>element_lists_item</class> <datasource>.elements</datasource> <script> function onListChanged() super.onListChanged(); local bLocked = WindowManager.getLockedState(getDatabaseNode().getParent()); if bLocked then window.element_iedit.setVisible(false); else if getWindowCount() > 0 then window.element_iedit.setVisible(true); else window.element_iedit.setVisible(false); end end end function onDrop(x, y, draginfo) local bLocked = WindowManager.getLockedState(getDatabaseNode().getParent()); if not bLocked then if draginfo.isType("reference_element") then local win = draginfo.getCustomData(); local source = win.getDatabaseNode(); addElement(source); return true; elseif draginfo.isType("shortcut") then local class = draginfo.getShortcutData(); local source = draginfo.getDatabaseNode(); if source and class == "reference_element" then addElement(source); return true; end end end return false; end function addElement(source) local newentry; local newnode; if source.getChild("name") then local newname = source.getChild("name").getValue(); if newname~="" then for i,win in ipairs(getWindows()) do if win.name.getValue()==newname then Comm.deliverChatMessage({font="systemfont",text="Element '" .. newname .. "' is already present in the list"}); return nil; end end end end newentry = createWindow(); newnode = newentry.getDatabaseNode(); local sElementName = DB.getValue(source, "name", ""); newentry.name.setValue(sElementName); newentry.open.setTarget(source.getNodeName()); return newentry; end </script> </list_column> </sheetdata> </windowclass> <windowclass name="element_lists_item"> <sizelimits> <maximum> <height>20</height> </maximum> <minimum> <height>20</height> </minimum> </sizelimits> <script> function onInit() if super and super.onInit then super.onInit(); end local node = getDatabaseNode(); if not open.getValue() then open.setValue("reference_element",node.getNodeName()); end open.setVisible(true); end </script> <sheetdata> <genericcontrol name="rightanchor"> <anchored height="0" width="0"> <top /> <right /> </anchored> </genericcontrol> <button_idelete name="idelete"> <anchored width="18" height="18"> <top offset="1" /> <right parent="rightanchor" anchor="left" relation="relative" offset="0" /> </anchored> </button_idelete> <windowreferencefield name="open"> <bounds>0,1,18,18</bounds> <icon> <normal>button_link</normal> <pressed>button_link</pressed> </icon> <description> <field>name</field> </description> <script> function setTarget(path) setValue("reference_element",path); end </script> </windowreferencefield> <stringfield name="name"> <anchored> <to>open</to> <position>righthigh</position> <offset>5,0</offset> <size> <width>200</width> </size> </anchored> <font>sheettext</font> <disabled /> <script> function onDragStart(button, x, y, draginfo) draginfo.setType("shortcut"); draginfo.setShortcutData(window.open.getValue()); draginfo.setIcon(window.open.icon[1].normal[1]); return true; end </script> </stringfield> </sheetdata> </windowclass>
-
July 20th, 2022, 14:26 #2
it should be called (precisely) listname_iedit
-
July 20th, 2022, 19:11 #3
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,554
When in doubt, you can review the templates/scripts being run to create those objects and see exactly what they are doing. All the templates boil down to very simple window controls at their base level (number, string, list, etc.)
As damned mentioned, in order for the button_iedit to link up to the list in the way you expect, it needs to be named exactly "<ListControlName>_iedit".
In your example code, it would need to be named "element_list_iedit", instead of "element_iedit".
Regards,
JPG
-
July 21st, 2022, 06:29 #4
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks