Serge, could you confirm which executable name file is when displays NIL value at StatusBar ?
TreeItemValue bug
Moderator: Rathinagiri
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Re: TreeItemValue bug
Last edited by Pablo César on Fri Apr 28, 2017 1:59 pm, edited 1 time in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Re: TreeItemValue bug
Pablo, as Serge says, are diffrents statuses on yours apps, but I don't understend "3.4.4 Patched". On my untouched 3.4.4 works perfect:
PS. For what reason do you want to use ON CHANGE OnChangeTree (This.TreeItemValue) instead of ON CHANGE OnChangeTree (This.Value)
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
- Attachments
-
- demo.7z
- (1.38 MiB) Downloaded 273 times
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Re: TreeItemValue bug
Thanks Edward for your prompt reponse.
Do you considered right the first value at StatusBar ? I mean the value of TreeItemValue ?
Because I want to have the right value, not the NIL value. This untouched HMG version is with that problem.
And I wish to make a routine based on TreeItemValue.
#1 So, is it a bug ? Can be solved ? The solution presented is not correct ? How it can drive thru the right TreeItemValue ?
More one question: Have you tested by clicking at By untouched HMG version at events doesn't switches images by default. So, we only get change by forcing thru OnExpand/OnCollapse UDF. Right ?
But with wrong value ?
TreeItemValue is not displaying with the "touched" HMG version. That's is the point for I wrote #1 (red color).
Do you considered right the first value at StatusBar ? I mean the value of TreeItemValue ?
Because I want to have the right value, not the NIL value. This untouched HMG version is with that problem.
And I wish to make a routine based on TreeItemValue.
#1 So, is it a bug ? Can be solved ? The solution presented is not correct ? How it can drive thru the right TreeItemValue ?
More one question: Have you tested by clicking at By untouched HMG version at events doesn't switches images by default. So, we only get change by forcing thru OnExpand/OnCollapse UDF. Right ?
But with wrong value ?
TreeItemValue is not displaying with the "touched" HMG version. That's is the point for I wrote #1 (red color).
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- serge_girard
- Posts: 3176
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: TreeItemValue bug
demo2.exe is giving NIL
Serge
Serge
There's nothing you can do that can't be done...
- serge_girard
- Posts: 3176
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: TreeItemValue bug
This is both: 1st demo2.exe
Serge
Serge
- Attachments
-
- tree.png (41.98 KiB) Viewed 6290 times
There's nothing you can do that can't be done...
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Re: TreeItemValue bug
Thank you Serge. So, demo2.exe is untouched HMG version.
Wrong value (NIL) --> wrong result...
Wrong value (NIL) --> wrong result...
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Re: TreeItemValue bug
Pablo, in my opinion, is correct. As Claudio wrote, property This.TreeItemValue can be used ONLY in events: on expand and on collapse.
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. For this reason, the node image does not change. Clicking on "+" or "-" does not cause the node to be selected. Property this.value reads the value of the selected node / item.
This.TreeItemValue property reads value of expaded / collapse node and ONLY this.
For all others events you should use this.value property.
In other words, the node / item image is changed only when it is focused (selected).
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.
Sorry for my hopeless English.
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. For this reason, the node image does not change. Clicking on "+" or "-" does not cause the node to be selected. Property this.value reads the value of the selected node / item.
This.TreeItemValue property reads value of expaded / collapse node and ONLY this.
For all others events you should use this.value property.
In other words, the node / item image is changed only when it is focused (selected).
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.
Sorry for my hopeless English.
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Re: TreeItemValue bug
First at all, I thank you Edward to keep with me in this discussing. Thank you for your interest and assistance.
Sorry my English is also not so good, but I need to make you understanding me and I will explain again.
"This.TreeItemValue can be used ONLY in events: on expand and on collapse", I do not say the opposite.
The problem as I say: is another one.
So tell me, Am I wrong in this thinking ?
Sorry but I think different and I will tell you why as follows.
Tell me one thing. When you click on to: (Clicking on the rounded red color)
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.
And more...
Try to imagining another needing. As you said with two different images based only, it's so easy.
But when you have different images for different NODES ? You will need a right ID.
When we have a ImageList you certainly will need the right value, current value even by click on "+" of TREE.
What in short I mean is: expand/collapse should not change the focus but also can not change its position to NIL.
NIL is not numeric, we can not find the current clicked item... not with NIL.
NIL it is wrong.
You do not need make focus with expand/collapse events but you are clicking on that... and that needs to be identificable.
Remarks:
Sorry my English is also not so good, but I need to make you understanding me and I will explain again.
I also agree with that but the event results are not correct, at least not for TreeItemValue.
"This.TreeItemValue can be used ONLY in events: on expand and on collapse", I do not say the opposite.
The problem as I say: is another one.
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.
So tell me, Am I wrong in this thinking ?
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)
Sorry but I think different and I will tell you why as follows.
Tell me one thing. When you click on to: (Clicking on the rounded red color)
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.
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.
And more...
Try to imagining another needing. As you said with two different images based only, it's so easy.
But when you have different images for different NODES ? You will need a right ID.
When we have a ImageList you certainly will need the right value, current value even by click on "+" of TREE.
What in short I mean is: expand/collapse should not change the focus but also can not change its position to NIL.
NIL is not numeric, we can not find the current clicked item... not with NIL.
NIL it is wrong.
You do not need make focus with expand/collapse events but you are clicking on that... and that needs to be identificable.
Remarks:
- (*1) When I said you "need" I mean with untouched HMG version. Wrong TreeItemValue value from HMG even at TREE for expand/collapse.
- (*2) Come on... it's an expression like as. "I can not believe in that".
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Re: TreeItemValue bug
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 ?
I wish to keep different nodes images by changing when be expanded/collapsed.
Do you think is it possible with current HMG ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Re: TreeItemValue bug
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 ?
Did you mean such a tree action?
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.
Point me to where is the definition of tree object (+) / (-)? This is not a Node. Nodes are: 'Root', 'Docs', 'Folder', 'Notes'
(+) / (-) these are elements that have no definition, and as such values in Tree. So they are not part of a tree - in the sense that Expanded / Collapsed does not affect tree values.
They only serve to change the presentation of tree elements. And therefore they are handled separately from the rest of the tree.