Can you check this out? (mac os)

Just starting out? Need help? Post your questions and find answers here.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Can you check this out? (mac os)

Post by wilbert »

Can't move the button on MacOS 13.1.1 which is logical.
The button is gadget number 2 and you are only catching events for gadget number 0.
Windows (x64)
Raspberry Pi OS (Arm64)
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: Can you check this out? (mac os)

Post by mestnyi »

Just this code works like a charm in the windows and linux.
So I wanted it to work in macos. :)
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Can you check this out? (mac os)

Post by wilbert »

mestnyi wrote:Just this code works like a charm in the windows and linux.
So I wanted it to work in macos. :)
On MacOS the button receives the events where the button covers the canvas, not the canvas behind the button.
Windows (x64)
Raspberry Pi OS (Arm64)
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: Can you check this out? (mac os)

Post by mestnyi »

Found a solution for Mac OS.
This is a very convenient solution to make canvas transparent.

Code: Select all

If OpenWindow(0, 0, 0, 220, 220, "Гаджет Канвас (Холст)", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ButtonGadget(2,10,10,70,20,"move me")
  
  CanvasGadget(0, 10, 10, 70, 20)
  If StartDrawing( CanvasOutput(0) )
    FillMemory( DrawingBuffer(), DrawingBufferPitch() * OutputHeight())
    StopDrawing()
  EndIf
  
  Repeat
    Event = WaitWindowEvent()
    
    If Event = #PB_Event_Gadget And EventGadget() = 0
      If EventType() = #PB_EventType_LeftButtonUp
        ResizeGadget(0,x,y,#PB_Ignore,#PB_Ignore)
        CompilerIf #PB_Compiler_OS = #PB_OS_Windows
          HideGadget(0,0)
        CompilerEndIf
      EndIf
      
      If EventType() = #PB_EventType_LeftButtonDown
        OffsetX = GetGadgetAttribute(0, #PB_Canvas_MouseX)
        OffsetY = GetGadgetAttribute(0, #PB_Canvas_MouseY)
        CompilerIf #PB_Compiler_OS = #PB_OS_Windows
          HideGadget(0,1)
        CompilerEndIf
      EndIf
      
      If (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(0, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
        x = WindowMouseX(0)-OffsetX
        y = WindowMouseY(0)-OffsetY
        
        ResizeGadget(2,x,y,#PB_Ignore,#PB_Ignore)
        CompilerIf #PB_Compiler_OS <> #PB_OS_Windows
          ResizeGadget(0,x,y,#PB_Ignore,#PB_Ignore)
        CompilerEndIf
      EndIf
    EndIf   
    
  Until Event = #PB_Event_CloseWindow
EndIf
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: Can you check this out? (mac os)

Post by mestnyi »

can you check what the "LeftClickEvent()" procedure returns?

Code: Select all

; https://www.purebasic.fr/english/viewtopic.php?t=60782
Procedure LeftClickEvent()
   Debug "click"
   Debug Str(EventMenu()) ; why return 111?
   Debug Str(EventGadget()) ; why return 111?
   Debug Str(EventWindow())
EndProcedure

If OpenWindow(111, 0, 0, 100, 100, "UnbindEvent", #PB_Window_SystemMenu )
   BindEvent(#PB_Event_LeftClick,@LeftClickEvent())
   
   Repeat
      Event = WaitWindowEvent()
   Until  Event = #PB_Event_CloseWindow
EndIf
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: Can you check this out? (mac os)

Post by charvista »

On my Windows 11 Home, it returns:
Click
0
0
111
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
Quin
Addict
Addict
Posts: 1133
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Can you check this out? (mac os)

Post by Quin »

Tested on Windows 10 Home (64-bit), and Windows 7 Ultimate (64-bit). Results are:
Click
0
0
111
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: Can you check this out? (mac os)

Post by mestnyi »

You need to check it on Mac OS :D
User avatar
mk-soft
Always Here
Always Here
Posts: 6252
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Can you check this out? (mac os)

Post by mk-soft »

mestnyi wrote: Thu Apr 11, 2024 9:02 pm can you check what the "LeftClickEvent()" procedure returns?

Code: Select all

; https://www.purebasic.fr/english/viewtopic.php?t=60782
Procedure LeftClickEvent()
   Debug "click"
   Debug Str(EventMenu()) ; why return 111?
   Debug Str(EventGadget()) ; why return 111?
   Debug Str(EventWindow())
EndProcedure

If OpenWindow(111, 0, 0, 100, 100, "UnbindEvent", #PB_Window_SystemMenu )
   BindEvent(#PB_Event_LeftClick,@LeftClickEvent())
   
   Repeat
      Event = WaitWindowEvent()
   Until  Event = #PB_Event_CloseWindow
EndIf
See PB SDK or PostEvent.

When an event is received, it is the object.

Code: Select all

Result = PostEvent(Event [, Window, Object [, Type [, Data]]])
The object is therefore queried with Event[Gadget, Menu, Timer].
Therefore, 'Event' must always be evaluated first.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Piero
Addict
Addict
Posts: 948
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Can you check this out? (mac os)

Post by Piero »

I can move it for a few pixels but only if I click EXACTLY on top-left corner... it's like it falls from the cursor…

Edit: saw you posted another:
mestnyi wrote: Fri Jul 03, 2020 11:35 pm Found a solution for Mac OS.
This is a very convenient solution to make canvas transparent.
This one "jumps away" from the cursor when I click it, but then I can move it

Mac Monterey M1
User avatar
Piero
Addict
Addict
Posts: 948
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Can you check this out? (mac os)

Post by Piero »

Found part of the problem: works better if monitor is NOT set to high (retina) resolution
WilliamL
Addict
Addict
Posts: 1252
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: Can you check this out? (mac os)

Post by WilliamL »

If all you want is for the button to move then this code works fine here and button moves smoothy. https://www.purebasic.fr/english/viewto ... 70#p557070

PS
click
111
111
111
MacBook Pro-M1 (2021), Sequoia 15.4, PB 6.20
Post Reply