canvas change cursor

Mac OSX specific forum
Wolfram
Enthusiast
Enthusiast
Posts: 567
Joined: Thu May 30, 2013 4:39 pm

canvas change cursor

Post 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
macOS Catalina 10.15.7
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: canvas change cursor

Post by Fred »

It's the expected behaviour
Post Reply