|
|
Home » U++ Library support » TreeCtrl » FIX - Single Click does not open/close items
FIX - Single Click does not open/close items [message #13464] |
Wed, 09 January 2008 23:33  |
loki
Messages: 36 Registered: October 2007
|
Member |
|
|
Hello,
if the TreeCtrl is scrolled to the left, the calculation for the one-click open/close goes wrong.
I think this fix it.
void TreeCtrl::DoClick(Point p, dword flags, bool down)
{
Point org = sb;
if(p.y + org.y > sb.GetTotal().cy)
return;
int i = FindLine(p.y + org.y);
const Line& l = line[i];
int x = levelcx + l.level * levelcx - org.x - (levelcx >> 1) /*- org.x*/;
if(p.x > x - 6 && p.x < x + 6) {
if(down)
Open(l.itemi, !IsOpen(l.itemi));
}
else {
if(down && IsSel(l.itemi)) {
selclick = true;
return;
}
SetFocus();
int q = cursor;
SetCursorLine(i, true, false, true);
if(multiselect) {
int id = GetCursor();
if(flags & K_CTRL) {
SelectOne(id, !IsSelected(id));
anchor = cursor;
}
else
if(flags & K_SHIFT)
ShiftSelect(anchor < 0 ? cursor : anchor, cursor);
else {
if(selectcount) SelClear(0);
SelectOne(id);
anchor = cursor;
}
}
if(cursor != q)
WhenAction();
}
}
Could it be, that withopen has no effect? In the testcase it does not work.
tree.Add(int parentid¸ const Image& img¸ Value v¸ bool withopen)
greetings
loki
|
|
|
|
|
|
|
Re: FIX - Single Click does not open/close items [message #13583 is a reply to message #13564] |
Tue, 15 January 2008 15:48   |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
I'm not sure about that.
The purpose of the check in Paint is to draw the +/- indicator, but adding the check to open means that the node can be opened when canopen == false if the node has children. This makes canopen redundant and seems like incorrect behaviour.
If you want consistency I would rather remove the check from Paint:
if(m.canopen) { // or possibly: && m.child.GetCount())
Image im = m.isopen ? CtrlImg::treeminus() : CtrlImg::treeplus();
op -= im.GetSize() / 2;
w.DrawImage(op.x, op.y, im);
Why would you want to indicate to the user that the node can be opened when it can't actually be opened (canopen == false)?
[Updated on: Tue, 15 January 2008 15:53] Report message to a moderator
|
|
|
Re: FIX - Single Click does not open/close items [message #13589 is a reply to message #13583] |
Tue, 15 January 2008 20:54   |
loki
Messages: 36 Registered: October 2007
|
Member |
|
|
Ok. I have corrected it to match the painting. But if the painting is wrong, my correction is also wrong...
In other words we should change the painting. I think you are right. (I had an other meaning about canopen).
1) (canopen && childcount > 0) ---> +/- is drawn.
2) (canopen && childcount <= 0) ---> +/- is not drawn.
3) (!canopen && childcount > 0) ---> +/- is drawn in disabled state (grey)
4) (!canopen && childcount <= 0) ---> +/- is not drawn.
if(m.child.GetCount()) {
Image im;
if(m.canopen)
im = m.isopen ? CtrlImg::treeminus() : CtrlImg::treeplus();
else
im = m.isopen ? CtrlImg::treeminusgrey() : CtrlImg::treeplusgrey();
op -= im.GetSize() / 2;
w.DrawImage(op.x, op.y, im);
}
treeminusgrey and treeplusgrey are new. I don't know if there is a drawing function which could grey the normal ones.
Is this ok?
greetings
loki
[Updated on: Tue, 15 January 2008 21:40] Report message to a moderator
|
|
|
|
|
|
|
Goto Forum:
Current Time: Sat Apr 26 14:58:01 CEST 2025
Total time taken to generate the page: 0.01115 seconds
|
|
|