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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Commandgroup does not update "value" on rightclick

Status
Not open for further replies.

mibosoft

Programmer
Jul 23, 2002
106
SE
Hi,
I would like to perform a certain task for rightclick on a button in a commandgroup but the problem is that "value" is only updated on click(). Example that shows the problem:

PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.addobject('cmd','myCmdGroup')
oform1.cmd.visible =.t.
oform1.Show
RETURN

DEFINE CLASS form1 AS form
DoCreate = .T.
Name = "Form1"
ENDDEFINE

DEFINE CLASS myCmdGroup AS COMMANDGROUP
AUTOSIZE = .T.
BUTTONCOUNT = 4

PROCEDURE CLICK
??THIS.VALUE AT 20 && Value=button
ENDPROC

PROCEDURE RIGHTCLICK
??THIS.VALUE AT 30 && Value=last click()
ENDPROC

ENDDEFINE

*Does anyone have a tip?
*Thanks,
*Micael
 
Can you use AMouseobj() in the rightclick method to determine what object is under the mouse?

Set your value there and go on your way.

Although, remember that a right-click is NOT a "blessed" selection mechanism. Technically, Value *shouldn't* be set on a right-click.
 
It's a good idea to use the rightclick() only
for context menus.

This is the expected behaviour of the button and may
confuse users who are familiar with GUI systems.

Although I break the habit from time to time, I try to
not use the rightclick() event for anything but context
menus.

Darrell
 
Just to add to the others. The Click Event is correct because focus is set on the currect button when you press on it.

The RightMouse Click Event - is set on container, not the buttom. Therefore, if click-on Command1 and then move your mouse over command3 and right-click. The current value will still be 1 because the right mouse click event is on the container and you have not moved away from the container.

If you want the right mouse to be button specific, the right mouse click code must go in the button - not the container.



Jim Osieczonek
Delta Business Group, LLC
 
Hi

Just a coincidence !
***********************************
I have reported the follwoing to Microsoft few days back.
The Option group also behaves the same way.
If you do the code in the RightClick event of individual buttons, then, the behaviour is fine. Only the Click event behaves correctly when coded in the click of the group container. I am afraid this is a bug. :-(
***************************************************
* From ramani (Subramanian.G )
* email: ramani_g@yahoo.com
* web: *
* Just copy the code and run it to see possible Bugs
* This is present till VFP8 - SP1.
**************************************************
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN

**************************************************
DEFINE CLASS form1 AS form

DoCreate = .T.
Caption = "Form1"
Name = "Form1"

ADD OBJECT commandgroup1 AS commandgroup WITH ;
ButtonCount = 2, ;
Value = 1, ;
Height = 66, ;
Left = 24, ;
Top = 168, ;
Width = 94, ;
Name = "Commandgroup1", ;
Command1.Top = 5, ;
Command1.Left = 5, ;
Command1.Height = 27, ;
Command1.Width = 84, ;
Command1.Caption = "Command1", ;
Command1.Name = "Command1", ;
Command2.Top = 34, ;
Command2.Left = 5, ;
Command2.Height = 27, ;
Command2.Width = 84, ;
Command2.Caption = "Command2", ;
Command2.Name = "Command2"

ADD OBJECT label1 AS label WITH ;
Caption = "Label1", ;
Height = 156, ;
Left = 24, ;
Top = 12, ;
Width = 324, ;
Name = "Label1"

PROCEDURE commandgroup1.RightClick
DO CASE
CASE This.Value = 1
WAIT WINDOW "Right Click Event of "+This.Buttons(This.Value).Caption NOWAIT NOCLEAR
CASE This.Value = 2
WAIT WINDOW "Right Click Event of "+This.Buttons(This.Value).Caption NOWAIT NOCLEAR
ENDCASE
ENDPROC

PROCEDURE commandgroup1.Click
DO CASE
CASE This.Value = 1
WAIT WINDOW "Click Event of "+This.Buttons(This.Value).Caption NOWAIT NOCLEAR
CASE This.Value = 2
WAIT WINDOW "Click Event of "+This.Buttons(This.Value).Caption NOWAIT NOCLEAR
ENDCASE
ENDPROC

PROCEDURE label1.Init
cMessage = "1. Click on Command1 and Right Click on Command2" ;
+ CHR(13) + "2. Click on Command2, and Right Click on Command1" ;
+ CHR(13) + "Notice that the Right Click only takes the button value of last " ;
+ CHR(13) + "click event and NOT the RIGHT click event. " ;
+ "The same is " + CHR(13) + "true in Option Buttons as well."

This.Caption = cMessage
ENDPROC

ENDDEFINE
*
*-- EndDefine: form1
**************************************************



____________________________________________
ramani - (Subramanian.G) :-)
 
Hi

Again... I just to want to add a solution to this.

Add the following code..
CommandGroup.MouseMoveEvent
***************************
LPARAMETERS nButton, nShift, nXCoord, nYCoord

LOCAL oButton
oButton = SYS(1270)
WITH This
FOR I = 1 TO .ButtonCount
IF .Buttons(i).Name = oButton.Name
This.Value = i
EXIT
ENDIF
ENDFOR
ENDWITH
*************************

This will solve the problem. This is my own solution. If I get any repy from Microsoft, I will update here for everyones benefit.

:-)

____________________________________________
ramani - (Subramanian.G) :-)
 
Hi

Sorry the above may be changed as given below..(The copied one was from my stale project. Later on I moved it to a appropriate event to avoid overhead while mouse movement.)

CommandGroup.RightClickEvent
****************************
oButton = SYS(1270)
WITH This
FOR I = 1 TO .ButtonCount
IF .Buttons(i).Name = oButton.Name
This.Value = i
EXIT
ENDIF
ENDFOR
ENDWITH
* Do whatever...
WAIT WINDOW This.Buttons(This.Value).Caption NOWAIT NOCLEAR

:-)

____________________________________________
ramani - (Subramanian.G) :-)
 
Thanks all for the help. I think I can workaround it now. I normally try to avoid using rightclick but this time it seemed like a good idea.

Cheers,
Micael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top