Page 2 of 2
Re: Can you check this out? (mac os)
Posted: Mon Nov 06, 2017 1:58 pm
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.
Re: Can you check this out? (mac os)
Posted: Mon Nov 06, 2017 3:56 pm
by mestnyi
Just this code works like a charm in the windows and linux.
So I wanted it to work in macos.

Re: Can you check this out? (mac os)
Posted: Mon Nov 06, 2017 4:00 pm
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.
Re: Can you check this out? (mac os)
Posted: Fri Jul 03, 2020 11:35 pm
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
Re: Can you check this out? (mac os)
Posted: Thu Apr 11, 2024 9:02 pm
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
Re: Can you check this out? (mac os)
Posted: Sun Apr 14, 2024 11:00 am
by charvista
On my Windows 11 Home, it returns:
Click
0
0
111
Re: Can you check this out? (mac os)
Posted: Sun Apr 14, 2024 3:12 pm
by Quin
Tested on Windows 10 Home (64-bit), and Windows 7 Ultimate (64-bit). Results are:
Click
0
0
111
Re: Can you check this out? (mac os)
Posted: Sun Apr 14, 2024 9:24 pm
by mestnyi
You need to check it on Mac OS

Re: Can you check this out? (mac os)
Posted: Mon Apr 15, 2024 8:31 am
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.
Re: Can you check this out? (mac os)
Posted: Mon Apr 15, 2024 4:12 pm
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
Re: Can you check this out? (mac os)
Posted: Mon Apr 15, 2024 4:31 pm
by Piero
Found part of the problem: works better if monitor is NOT set to high (retina) resolution
Re: Can you check this out? (mac os)
Posted: Mon Apr 15, 2024 9:35 pm
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