TreeItemValue bug

Moderator: Rathinagiri

User avatar
Pablo César
Posts: 4053
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 175 times

Re: TreeItemValue bug

Post by Pablo César » Fri Apr 28, 2017 1:57 pm

serge_girard wrote:
Fri Apr 28, 2017 1:38 pm
One says 8 On Change and the other NIL
Serge, could you confirm which executable name file is when displays NIL value at StatusBar ?
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

edk
Posts: 114
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 28 times
Been thanked: 53 times

Post by edk » Fri Apr 28, 2017 1:59 pm

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:

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
Bez tytułu3.png
Bez tytułu3.png (10.61 KiB) Viewed 143 times
PS. For what reason do you want to use ON CHANGE OnChangeTree (This.TreeItemValue) instead of ON CHANGE OnChangeTree (This.Value)
Attachments
demo.7z
(1.38 MiB) Downloaded 9 times

User avatar
Pablo César
Posts: 4053
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 175 times

Post by Pablo César » Fri Apr 28, 2017 2:15 pm

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
Screen206.png
Screen206.png (6.45 KiB) Viewed 138 times
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

User avatar
serge_girard
Posts: 1747
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 226 times
Been thanked: 44 times
Contact:

Post by serge_girard » Fri Apr 28, 2017 2:17 pm

demo2.exe is giving NIL

Serge

User avatar
serge_girard
Posts: 1747
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 226 times
Been thanked: 44 times
Contact:

Post by serge_girard » Fri Apr 28, 2017 2:22 pm

This is both: 1st demo2.exe

Serge
Attachments
tree.png
tree.png (41.98 KiB) Viewed 137 times

User avatar
Pablo César
Posts: 4053
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 175 times

Post by Pablo César » Fri Apr 28, 2017 3:08 pm

Thank you Serge. So, demo2.exe is untouched HMG version.

Wrong value (NIL) --> wrong result... :|
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

edk
Posts: 114
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 28 times
Been thanked: 53 times

Post by edk » Fri Apr 28, 2017 3:55 pm

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.

User avatar
Pablo César
Posts: 4053
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 175 times

Post by Pablo César » Fri Apr 28, 2017 5:14 pm

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.
edk wrote:
Fri Apr 28, 2017 3:55 pm
Pablo, in my opinion, is correct. As Claudio wrote, property This.TreeItemValue can be used ONLY in events: on expand and on collapse.
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. :shock:

The problem as I say: is another one.
 
 
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.
You are absolutly right but not for the same reason that you "need" (*1) to force TreeItemValue to NIL.
So tell me, Am I wrong in this thinking ?
 
 
edk wrote:
Fri Apr 28, 2017 3:55 pm
For all others events you should use this.value property.
That's means that only for TREE is different ? Come on... (*2) Are you sure to be needed like this ?
 
 
In other words, the node / item image is changed only when it is focused (selected)
By the untouched HMG version yes. But I do not agree with that.

Sorry but I think different and I will tell you why as follows.

Tell me one thing. When you click on to:
Screen206.png
Screen206.png (6.45 KiB) Viewed 110 times
(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.
 
 
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.
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.

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

User avatar
Pablo César
Posts: 4053
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 175 times

Post by Pablo César » Fri Apr 28, 2017 5:56 pm

Edward, probably with your technical experience you could make it work this:
Demo3.rar
Source files
(2.31 KiB) Downloaded 13 times
I wish to keep different nodes images by changing when be expanded/collapsed.
 
Screen207.png
Screen207.png (8.66 KiB) Viewed 103 times
 
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

edk
Posts: 114
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 28 times
Been thanked: 53 times

Post by edk » Fri Apr 28, 2017 7:23 pm

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 ?
Pablo.
Did you mean such a tree action?
bez tytułu.PNG
bez tytułu.PNG (38.03 KiB) Viewed 96 times
Demo3.7z
(1.09 MiB) Downloaded 7 times

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
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.
Let me disagree with you.
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.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests