Page 1 of 1

canvas change cursor

Posted: Fri Dec 02, 2016 2:18 pm
by Wolfram
The mouse cursor change on leaving the canvas. I think that makes no sense, because the developer has no influence on it and it will not
automatically change back on enter.

Code: Select all

Global Window_0, Canvas, NewCursor

Procedure ChangeCurser()

    Cursor = CreateImage(#PB_Any, 30, 30)

    Hotspot.NSPoint
    Hotspot\x = 15 
    Hotspot\y = 10
    
    NewCursor = CocoaMessage(0, 0, "NSCursor alloc")
    CocoaMessage(0, NewCursor, "initWithImage:", ImageID(Cursor), "hotSpot:@", @Hotspot)
    CocoaMessage(0, NewCursor, "set")

EndProcedure


Procedure Window_0_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False

    Case #PB_Event_Menu
      Select EventMenu()
   Case #PB_Menu_Quit
          ProcedureReturn #False
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
        Case Canvas
          If EventType() = #PB_EventType_LeftButtonDown
            ChangeCurser()
          EndIf
          
          
      EndSelect
  EndSelect
  ProcedureReturn #True
EndProcedure


  Window_0 = OpenWindow(#PB_Any, x, y, 200, 120, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  Canvas = CanvasGadget(#PB_Any, 10, 10, 180, 100)
  
  Repeat
    
  Until WaitWindowEvent() = 4
  
ChangeCurser()

Repeat
  event = WaitWindowEvent()
Until Window_0_Events(event) = #False

Re: canvas change cursor

Posted: Wed Feb 15, 2017 9:20 am
by Fred
It's the expected behaviour