Re: TreeItemValue bug
Posted: Fri Apr 28, 2017 1:57 pm
Serge, could you confirm which executable name file is when displays NIL value at StatusBar ?
Exclusive forum for HMG, a Free / Open Source xBase WIN32/64 Bits / GUI Development System
http://hmgforum.com/
Serge, could you confirm which executable name file is when displays NIL value at StatusBar ?
Code: Select all
#include <hmg.ch>
FUNCTION Main()
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 286 ;
HEIGHT 460 ;
TITLE 'Tree Expand and Collapse Sample' ;
MAIN
DEFINE STATUSBAR FONT "Courier New" SIZE 10
STATUSITEM ""
END STATUSBAR
DEFINE TREE Tree_1 AT 10,10 WIDTH 260 HEIGHT 400 VALUE 3 ;
ON CHANGE OnChangeTree(This.TreeItemValue) ;
ON EXPAND (Form_1.Tree_1.ImageIndex(This.TreeItemValue):={1,1}, OnExpandTree(This.TreeItemValue) );
ON COLLAPSE (Form_1.Tree_1.ImageIndex(This.TreeItemValue):={0,1}, OnCollapseTree(This.TreeItemValue) );
NODEIMAGES { "NODE_CL", "NODE_OP" } ;
ITEMIMAGES { "PAGE_CL", "PAGE_OP" } ;
NOROOTBUTTON
//ITEMIDS
NODE 'Root'
TREEITEM 'Item 1.1'
TREEITEM 'Item 1.2'
TREEITEM 'Item 1.3'
NODE 'Docs'
TREEITEM 'Docs 1'
TREEITEM 'Docs 2'
END NODE
NODE 'Notes'
TREEITEM 'Notes 1'
TREEITEM 'Notes 2'
TREEITEM 'Notes 3'
TREEITEM 'Notes 4'
TREEITEM 'Notes 5'
END NODE
END NODE
END TREE
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
RETURN Nil
FUNCTION OnChangeTree(nItem)
Form_1.StatusBar.Item(1) := hb_ValToStr(nItem)+" - On Change"
RETURN Nil
FUNCTION OnExpandTree(nItem)
Form_1.StatusBar.Item(1) := hb_ValToStr(nItem)+" - On Expand"
RETURN Nil
FUNCTION OnCollapseTree(nItem)
Form_1.StatusBar.Item(1) := hb_ValToStr(nItem)+" - On Collapse"
RETURN Nil
I also agree with that but the event results are not correct, at least not for TreeItemValue.
You are absolutly right but not for the same reason that you "need" (*1) to force TreeItemValue to NIL.Because these events do not change the focus to the node, expanded/collapsed node is NOT selected, they can not be read by the this.value property.
That's means that only for TREE is different ? Come on... (*2) Are you sure to be needed like this ?
By the untouched HMG version yes. But I do not agree with that.In other words, the node / item image is changed only when it is focused (selected)
Yes, this I understood and then proceed in accordingly when is one type of node. But then you can not proceed rightly when the TreeItemValue is NIL.We can "deceive" the tree control by changing the unselect node image to the same as the select node image, at the time of the expand event.
Pablo.Pablo César wrote: ↑Fri Apr 28, 2017 5:56 pm Edward, probably with your technical experience you could make it work this:
I wish to keep different nodes images by changing when be expanded/collapsed.
Do you think is it possible with current HMG ?
Code: Select all
#include <hmg.ch>
FUNCTION Main()
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 286 ;
HEIGHT 460 ;
TITLE 'Tree Expand and Collapse Sample' ;
MAIN
DEFINE STATUSBAR FONT "Courier New" SIZE 10
STATUSITEM ""
END STATUSBAR
DEFINE TREE Tree_1 AT 10,10 WIDTH 260 HEIGHT 400 VALUE 3 ;
ON CHANGE OnChangeTree(This.Value) ;
ON EXPAND OnExpandTree(This.TreeItemValue);
ON COLLAPSE OnCollapseTree(This.TreeItemValue);
NODEIMAGES { "NODE1_CL", "NODE1_OP" } ;
ITEMIMAGES { "PAGE_CL", "PAGE_OP" } ;
NOROOTBUTTON
//ITEMIDS
NODE 'Root'
TREEITEM 'Item 1.1' IMAGES { "PAGE_CL", "PAGE_OP" }
TREEITEM 'Item 1.2' IMAGES { "PAGE_CL", "PAGE_OP" }
TREEITEM 'Item 1.3' IMAGES { "PAGE_CL", "PAGE_OP" }
NODE 'Docs' IMAGES { "NODE1_CL", "NODE1_OP" }
TREEITEM 'Docs 1' IMAGES { "PAGE_CL", "PAGE_OP" }
TREEITEM 'Docs 2' IMAGES { "PAGE_CL", "PAGE_OP" }
END NODE
NODE 'Folder' IMAGES { "NODE2_CL", "NODE2_OP" }
TREEITEM 'Folder 1' IMAGES { "PAGE_CL", "PAGE_OP" }
TREEITEM 'Folder 2' IMAGES { "PAGE_CL", "PAGE_OP" }
END NODE
NODE 'Notes' IMAGES { "NODE3_CL", "NODE3_OP" }
TREEITEM 'Notes 1' IMAGES { "PAGE_CL", "PAGE_OP" }
TREEITEM 'Notes 2' IMAGES { "PAGE_CL", "PAGE_OP" }
TREEITEM 'Notes 3' IMAGES { "PAGE_CL", "PAGE_OP" }
TREEITEM 'Notes 4' IMAGES { "PAGE_CL", "PAGE_OP" }
TREEITEM 'Notes 5' IMAGES { "PAGE_CL", "PAGE_OP" }
END NODE
END NODE
END TREE
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
RETURN Nil
FUNCTION OnChangeTree(nItem)
Form_1.StatusBar.Item(1) := hb_ValToStr(nItem)+" - On Change"
RETURN Nil
FUNCTION OnExpandTree(nItem)
Local currImageIndex:=Form_1.Tree_1.ImageIndex(nItem)
Local expandImageIndex:={currImageIndex[2], currImageIndex[2]}
Form_1.Tree_1.ImageIndex(nItem):=expandImageIndex
Form_1.StatusBar.Item(1) := hb_ValToStr(nItem)+" - On Expand"
RETURN Nil
FUNCTION OnCollapseTree(nItem)
Local currImageIndex:=Form_1.Tree_1.ImageIndex(nItem)
Local collapseeImageIndex:={currImageIndex[1]-1, currImageIndex[2]}
Form_1.Tree_1.ImageIndex(nItem):=collapseeImageIndex
Form_1.StatusBar.Item(1) := hb_ValToStr(nItem)+" - On Collapse"
RETURN Nil
Let me disagree with you.Pablo César wrote: ↑Fri Apr 28, 2017 5:14 pm It's part of TREE, right ? (Yes or Not)
When you clicked on "+" or "-" is it at node one or on what else ? In Node one ? (Yes or Not)
So, if all answer are "yes" it's by the same item, then you are quite selecting that or at least making position on the same item, same node, so this node should represents an ID and it should do it with the right ID. Not with NIL ID value.
I am pretty sure what the user expect to be instead that.