 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jayme Jeffman Filho Guest
|
Posted: Wed Jun 23, 2004 8:38 pm Post subject: Using TTreeView. |
|
|
Hello,
I would like to have the TreeView of my application to allow node selection when the user click on it using the mouse right button. I've set the RightClickSelect to true, it is not working yet.
I had a PopUp menu set to AutoPopUp, this seems not allowing the user to select another node on the TreeView except when using the mouse left button.
Could any body give some direction on how to solve this problem? I would like to have my TreeView behave as the TreeView on Windows Explorer.
Thanks a lot.
Jayme
|
|
| Back to top |
|
 |
JD Guest
|
Posted: Thu Jun 24, 2004 1:07 am Post subject: Re: Using TTreeView. |
|
|
"Jayme Jeffman Filho" <jjeffman (AT) cpovo (DOT) net> wrote:
Please wrap your lines when you post. Your editor may visually
wrap them for you but you need to enter a hard return at the
end of each line.
| Quote: | [...] Could any body give some direction on how to solve
this problem?
|
There are a couple of ways to accomplish what you want. One is
to use the TreeView's OnMouseDown event:
void __fastcall TForm1::TreeView1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
{
if( Shift.Contains(ssRight) )
{
TreeView1->Selected = TreeView1->GetNodeAt( X, Y );
}
}
~ JD
|
|
| Back to top |
|
 |
Pete Fraser Guest
|
Posted: Thu Jun 24, 2004 8:07 am Post subject: Re: Using TTreeView. |
|
|
I don't think that's quite right.
Shouldn't it be: (The other code waits for the Right Shift key)
void __fastcall TForm1::TreeView1MouseDown(TObject *Sender, TMouseButton
Button, TShiftState Shift, int X, int Y)
{
if( Button == mbRight )
{
TreeView1->Selected = TreeView1->GetNodeAt( X, Y );
}
}
Rgds Pete
"JD" <nospam (AT) nospam (DOT) com> wrote
| Quote: |
"Jayme Jeffman Filho" <jjeffman (AT) cpovo (DOT) net> wrote:
Please wrap your lines when you post. Your editor may visually
wrap them for you but you need to enter a hard return at the
end of each line.
[...] Could any body give some direction on how to solve
this problem?
There are a couple of ways to accomplish what you want. One is
to use the TreeView's OnMouseDown event:
void __fastcall TForm1::TreeView1MouseDown(TObject *Sender, TMouseButton
Button, TShiftState Shift, int X, int Y)
{
if( Shift.Contains(ssRight) )
{
TreeView1->Selected = TreeView1->GetNodeAt( X, Y );
}
}
~ JD
|
|
|
| Back to top |
|
 |
JD Guest
|
Posted: Thu Jun 24, 2004 9:49 am Post subject: Re: Using TTreeView. |
|
|
"Pete Fraser" <pete._no_spam_fraser (AT) frasersoft (DOT) nospam.net> wrote:
| Quote: | [...] The other code waits for the Right Shift key
|
Incorrect. First, the code doesn't wait for anything. Second,
ssRight referes to the right mouse button - not the right shift
key.
However, ssRight referes to the current state of the button at
the time the event executes which *could* be up. While I suspect
that that will never happen, it's reasonable to 'just be safe'
and check the Button parameter instead.
~ JD
|
|
| Back to top |
|
 |
Pete Fraser Guest
|
Posted: Thu Jun 24, 2004 11:24 am Post subject: Re: Using TTreeView. |
|
|
I meant that the code inside the 'if statement' will only trigger if right
shift key help down when mouse button is pressed
Incorrect:
From Help file:
"Use the OnMouseDown event handler to implement any special processing that
should occur as a result of pressing a mouse button.
The OnMouseDown event handler can respond to left, right, or center mouse
button presses and shift key plus mouse-button combinations. Shift keys are
the Shift, Ctrl, and Alt keys. X and Y are the pixel coordinates of the
mouse pointer in the client area of the Sender."
This allows the programmer to do different things according to whether the
shift key was pressed when the mouse button was pressed. I use it to do this
quite often.
Rgds Pete
"JD" <nospam (AT) nospam (DOT) com> wrote
| Quote: |
"Pete Fraser" <pete._no_spam_fraser (AT) frasersoft (DOT) nospam.net> wrote:
[...] The other code waits for the Right Shift key
Incorrect. First, the code doesn't wait for anything. Second,
ssRight referes to the right mouse button - not the right shift
key.
However, ssRight referes to the current state of the button at
the time the event executes which *could* be up. While I suspect
that that will never happen, it's reasonable to 'just be safe'
and check the Button parameter instead.
~ JD
|
|
|
| Back to top |
|
 |
Jayme Jeffman Filho Guest
|
Posted: Thu Jun 24, 2004 12:09 pm Post subject: Re: Using TTreeView. |
|
|
Hello JD,
"JD" <nospam (AT) nospam (DOT) com> wrote
| Quote: |
"Jayme Jeffman Filho" <jjeffman (AT) cpovo (DOT) net> wrote:
Please wrap your lines when you post. Your editor may visually
wrap them for you but you need to enter a hard return at the
end of each line.
|
Is this a rule for this NewsGroup ? Nobody has asked me to r
do this in other C++Builder NewsGroup. How many characters r
may a line have?
Thanks for answering my question.
Jayme.
|
|
| Back to top |
|
 |
Jayme Jeffman Filho Guest
|
Posted: Thu Jun 24, 2004 12:21 pm Post subject: Re: Using TTreeView. |
|
|
Hello Peter,
Thanks for your answer.
I'm accustomed to use the "Button" parameter as you wrote
and it works very well at least on drag and drop operations.
The help file suggest the "mouse up" event, do you think it
can behave differently from "mouse down"?
Thanks,
Jayme.
|
|
| Back to top |
|
 |
JD Guest
|
Posted: Thu Jun 24, 2004 12:50 pm Post subject: Re: Using TTreeView. |
|
|
"Pete Fraser" <pete._no_spam_fraser (AT) frasersoft (DOT) nospam.net> wrote:
| Quote: | I meant that the code inside the 'if statement' will only
trigger if right shift key help down when mouse button is
pressed
|
I understand what you're saying but you're still wrong.
Nothing there precludes what I stated from being correct. If
you were going to look in the help file, you should have also
checked TShiftState before telling me I was wrong.
~ JD
|
|
| Back to top |
|
 |
JD Guest
|
Posted: Thu Jun 24, 2004 1:04 pm Post subject: Re: Using TTreeView. |
|
|
"Jayme Jeffman Filho" <jjeffman (AT) cpovo (DOT) net> wrote:
| Quote: |
Is this a rule for this NewsGroup ?
|
It's not a rule but if you use a browser and post a response (you can back out by clicking the back button) you'll see that it explicitly says to do so (I didn't wrap this line - how does it look to you):
http://newsgroups.borland.com/cgi-bin/dnewsweb?utag=&group=borland.public.cppbuilder.vcl.components.using&from_up=&from_down=82233&cmd_latest=Latest+Items
| Quote: | Nobody has asked me to in other C++Builder NewsGroup.
|
Not many will because it's not a rule. It's just difficult to
read (and understand) when one has to scroll from side to side.
| Quote: | How many characters may a line have?
|
Click the link and try posting.
BTW : r isn't the solution. Pressing the Enter key at the end
of the line is.
~ JD
|
|
| Back to top |
|
 |
JD Guest
|
Posted: Thu Jun 24, 2004 1:15 pm Post subject: Re: Using TTreeView. |
|
|
"Jayme Jeffman Filho" <jjeffman (AT) cpovo (DOT) net> wrote:
| Quote: | [...] The help file suggest the "mouse up" event, do you
think it=20 can behave differently from "mouse down"?
|
Of course it will. That's why I chose the OnMouseDown event to
begin with. Using OnMouseUp won't work because the Selected
property won't be changed until AFTER the popup has closed.
You explicitly ask for behavior that mimics Windows Explorer.
Look closely at your portion of this post. What is that '=20'?
~ JD
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|