Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to use right mouse botton on other componets

Status
Not open for further replies.

tid

Programmer
Oct 22, 2003
23
IL
Hi,
1.i have a componet. from some reosen the right click is doing something when clicked on that - but this componets has NO right click event.
where this event coming from ?
2. how can i make the right click do something else like showing a popup up menu on mouse poistion (and just if its poistion is on that specific componet array !).
notice : that componet has no popup menu property so i need another way to show the popup menu in that location.
i now something on show(int,int) function comuing with popup menu componet but this didn't work since i dont know how to get the 2 int's (i sespect them to be the X,Y of the mouse position but i don't know how to get them...).

thank you all and sorry for the mess in the question and the spelling...
Tid.
 
Hi,
1. Have no idea ;)
2. You need 2 things : a) OnMouseUp event for your control, b) pop-up menu on your form. Now, OnMouseUp will give you mouse button and coordinates IN CLIENT SPACE where event occured. Check your conditions, and if satisfied, call MyPopUpMenu->PopUp(NewX, NewY). Beware that <NewX,Newy> are in SCREEN SPACE, so you will need to convert those client-space coordinates to screen coordinates before calling PopUp - use TPointScreenCoord = MyComponent->ClientToScreen(TPointMadeOfMouseCoords) to convert it. And, that should do the job!
 
first, thank for your replay.
now...
i need the onmouseup will be for the RIGHT click . the normal click (left click) is used for something else (like selecting a date on calendar...).
i need the right click to show the popup.
how can i make the OnMouseUp response to the right click ?
Tid.
 
Hi,
as I said - there is &quot;TMouseButton Button&quot; parameter in OnMouseUp event, which determines the button. So, you should do something like :
.
.
.
if (Button == mbRight)
{
// 1. convert X,Y to screen coordinates (NewX, NewY)
// 2. do something like : MyPopUp->PopUp(NewX, NewY)
}
else if (Button == mbLeft)
{
// do something else if needed or do nothing ...
}
 
Thanks.
from some reosen the OnMouseUp event is Dynamic for that componet.
when i just set it as you said its doesn'ty work at all (not for the right nor the left button, i tried to put a pbrekpoint and nothing worked).
do i need to override this dynamic method ?
How to do it ?

Thanks.
 
Dynamic, what do you mean by &quot;dynamic&quot;? Can you select that event in Object Inspector or not? And what kind of component is that?
 
o.k.
you CAN select the Onmouseup in the Object Inspector.
BUT when you write down the function the program don't call it when the mouse is presed.
the componet is part of TMS (3rd party componet) - its a calendar componet.
when you press down the left click you change day on the calnedar. but the componet dont call its OnMouseUp event.
i looked in the header file of that componet and that is event is something like
DYNAMIC __fastcall Tform::OnMouseUp .... or something like that.
in help of borland its said that dynamic is something like vistual...
This is all the story.
so my componet don't response to The Onmouseevent and i don't know how to make it call it.
i hope this will cover everything.
Tid
 
I've seen that kind of behaviour with some controls! Looks to me that overriding of methods which respond to events was not done in a proper way. Anyway, try to use OnMouseDown instead (it helped me in some cases).
 
thing_OnMouseUp (sender)
{
thing_rightButtonclick (sender);
}

or

thing_Buttonclick (sender)
{
thing_OnMouseUp (sender);
}


tomcruz.net
 
What is that butthead ?
can you do it more detailed ?
Or, can somebody tell me how to override the onmoudeup event ?
Thanks.
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top