Skip to content

Too may GraphicsWindow.MouseMove events #73

@nonkit

Description

@nonkit

Too may GraphicsWindow.MouseMove events occur in Debug.

OnMouseMove

Sample code:

' Drag and Drop Sample
' Original Program ID NWQ566
' Modified for SBO v0.91

'GraphicsWindow.Title = "Drag and Drop Sample"
Init()
MainLoop()

Sub MainLoop
  ' main loop
  While "True"
    While Not[mouseDown]  ' wait until mouse down
      Program.Delay(200)
    EndWhile
    x1 = Shapes.GetLeft(rect)
    y1 = Shapes.GetTop(rect)
    x2 = x1 + size
    y2 = y1 + size
    If (x1 <= mx) Then
      If (mx < x2) Then
        If (y1 <= my) Then
          If (my < y2) Then
            ' mouse clicked on the rectangle
            dx = mx - x1
            dy = my - y1
            While mouseDown ' move the rectangle while mouse down
              If mouseMove Then
                Shapes.Move(rect, mx - dx, my - dy)
                mouseMove = "False"
              EndIf
            EndWhile
          EndIf
        EndIf
      EndIf
    EndIf
  EndWhile
EndSub

Sub Init
  ' initialization
  Not["True"] = "False"
  Not["False"] = "True"
  GraphicsWindow.BackgroundColor = "#333333"
  GraphicsWindow.PenWidth = 0
  GraphicsWindow.BrushColor = "Gold"
  size = 40
  rect = Shapes.AddEllipse(size, size)
  mouseDown = "False"
  mouseMove = "False"
  GraphicsWindow.MouseDown = OnMouseDown
  GraphicsWindow.MouseUp = OnMouseUp
  GraphicsWindow.MouseMove = OnMouseMove
EndSub

Sub OnMouseDown
  ' mouse down event handler
  mx = GraphicsWindow.MouseX
  my = GraphicsWindow.MouseY
  mouseDown = "True"
EndSub

Sub OnMouseUp
  ' mouse up event handler
  mouseDown = "False"
EndSub

Sub OnMouseMove
  ' mouse move event handler
  mx = GraphicsWindow.MouseX
  my = GraphicsWindow.MouseY
  mouseMove = "True"
EndSub

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/runtimeIssues related to runtime engine

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions