k y m a • t w e a k y — the kyma collective || view the current website || February 2015 Archive

/ WebHome / How.ModifyMouseToEventTool


How Section

How do I...
Add a question...


All Sections


Login / Register 
Change password
Forgot password?

Symbolic Sound

Kyma Forum
Eighth Nerve

TWiki Links

TWiki Formatting FAQ
What is TWiki?
%SESSION_ENDIF% twiki.org

Question (or Task)

I have been trying to edit the MouseToEvent.pci tool and wanted to make the following changes:

  1. 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?
  2. 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

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

© 2003-2014 by the contributing authors. / You are TWikiGuest