kyma•tweaky . How . ModifyMouseToEventTool
|
I have been trying to edit the MouseToEvent.pci tool and wanted to make the following changes:
- Limit Event Generation from the tool to when the cursor is within the ActiveArea window.
- I tried something similar to the following code, within the UpdateXY code block in the InitialState state:
(((pt x > bnds topLeft) & (pt x < bnds extent)) | ((pt y > topCenter) & (pt y < bottomCenter))) ifTrue: [#ActiveState]
BUT I haven't managed to get the syntax correct yet!
- I wanted to ask if firstly it looks like I'm going about this in the right way and also on the ifFalse condition what state can I jump to if I don't want it to actually do anything? Leave out the ifFalse condition?
- I would like to alter the ActiveState, so that it is only active (only generating events) when the Mouse is down - i.e. clicked on the 'ActiveArea' - on Mouse up, the events should cease to be created.
Are there any SmallTalk messages regarding mouse events? How can I test for them? and what is the syntax for them?
Best regards, Andrew
-- AndrewPurdy - 12 Nov 2003
The way the tool is set up, the UpdateXY code block is used as a subroutine with a side effect of setting the X and Y global variables. Because of this, you cannot use it to change states. The best way to do what you are trying to do is to change the last trigger in the ActiveState from true to:
| bnds pt |
bnds := ActiveArea bounds.
pt := ActiveArea controller sensor cursorPoint.
"Update values only when mouse in active area."
bnds containsPoint: pt
this limits the update of the graphic and the sending of the values to the Capybara to occur only when the mouse is within the ActiveArea.
If you use the following code instead, then the updates are limited to when the mouse button is down and the mouse is within the ActiveArea:
| bnds pt |
bnds := ActiveArea bounds.
pt := ActiveArea controller sensor cursorPoint.
"Update values only when mouse in active area."
(ActiveArea controller sensor anyButtonPressed) and: [bnds containsPoint: pt]
-- KurtHebel - 12 Nov 2003
WebForm |
Question: | How do I modify the mouse to event tool to pay attention to the mouse button and the mouse location? |
Keywords: | tool, MouseToEvent.pci, Smalltalk |
----- Revision r1.1 - 12 Nov 2003 - 21:53 GMT - KurtHebel
|
Copyright © 1999-2014 by the contributing authors.
All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding kyma•tweaky? Send feedback.