Like my previous api attempts, no errors being shown, but nothing is
going on either.
Here is the source code I'm using to test this, it's an autohide bar on the
left of the screen:
(the alpha call is in the second if statement in the main loop)
Code: Select all
;
; /Applications/Programming/PureBasic/compilers/pbsoimporter /Applications/Programming/PureBasic/compilers/windowalpha.pbl /TO /Applications/Programming/PureBasic
;
; Icons for OSX apps are located in the .app/resources folder.
; Read the .app/info.plis file. Look for the following key
; and read it's string
; <key>CFBundleIconFile</key>
; <string>Icon</string>
; The icon file is in .icns format.
; #PB_Window_BorderLess #PB_Window_TitleBar
OpenWindow (0, 0, 100, 100, 600, #PB_Window_BorderLess , "ALB")
;UsePNGImageDecoder()
;LoadImage(1, "/Users/garrett/Documents/Development/PureBasicProjects/applaunch/add24.png")
;LoadImage(2, "/Users/garrett/Documents/Development/PureBasicProjects/applaunch/remove24.png")
;LoadImage(3, "/Users/garrett/Documents/Development/PureBasicProjects/applaunch/up24.png")
;LoadImage(4, "/Users/garrett/Documents/Development/PureBasicProjects/applaunch/down24.png")
;LoadImage(5, "/Users/garrett/Documents/Development/PureBasicProjects/applaunch/help24.png")
;LoadImage(6, "/Users/garrett/Documents/Development/PureBasicProjects/applaunch/close24.png")
;LoadImage(7, "/Users/garrett/Documents/Development/PureBasicProjects/applaunch/close24a.png")
CreateGadgetList(WindowID(0))
ButtonGadget(9, 2, 100, 32, 24, "X", #PB_Button_Left)
;ImageGadget(1, 2, 30, 24, 24, UseImage(1), #PB_EventType_LeftClick)
;ImageGadget(2, 26, 30, 24, 24, UseImage(2), #PB_EventType_LeftClick)
;ImageGadget(3, 50, 30, 24, 24, UseImage(3), #PB_EventType_LeftClick)
;ImageGadget(4, 74, 30, 24, 24, UseImage(4), #PB_EventType_LeftClick)
;ImageGadget(6, 74, 2, 24, 24, UseImage(6), #PB_EventType_LeftClick)
vMouseLocStatus = 1
vInitHold = 0
;InitMouse()
Event_Loop:
Delay(100)
If vInitHold < 10
vInitHold = vInitHold + 1
EndIf
If vInitHold = 9
Alpha.f = 0.5
SetWindowAlpha_(WindowID(0), Alpha)
MessageRequester("Notice", "Alpha On?", #PB_MessageRequester_Ok)
EndIf
; X is left to right
; Y is top to bottom
If vInitHold > 8
If vMouseX < 2 And vMouseLocStatus = 0
Gosub RollOut
EndIf
If vMouseX > 100 And vMouseLocStatus = 1
Gosub RollIn
EndIf
EndIf
vMouseX = DesktopMouseX()
vMouseY = DesktopMouseY()
EventID = WindowEvent()
If EventID = #PB_Event_CloseWindow
End
EndIf
GadgetID = EventGadgetID()
If GadgetID = 1
Goto Branch_1
ElseIf GadgetID = 6
Goto Branch_6
ElseIf GadgetID = 9
Goto Branch_9
EndIf
Goto Event_Loop
Branch_1:
;Result = RunProgram("/Applications/File/Xfolders.app")
Goto Event_Loop
Branch_6:
;SetGadgetState(6,UseImage(7))
;Repeat
; vMouseClick = MouseButton(1)
;Until vMouseClick = 0
;SetGadgetState(6,UseImage(6))
;Delay(500)
;Goto Branch_9
Goto Event_Loop
Branch_9:
End
RollIn:
vMouseLocStatus = 0
vWide = 0
vStep = 10
While vWide > -98
If vStep > 1
vStep = vStep - 1
EndIf
vWide = vWide - vStep
vMove = vWide
MoveWindow(vMove, 100)
Wend
MoveWindow(-98, 100)
Return
RollOut:
vMouseLocStatus = 1
vWide = 98
vStep = 10
While vWide > 2
If vStep > 1
vStep = vStep - 1
EndIf
vWide = vWide - vStep
vMove = -vWide
MoveWindow(vMove, 100)
Wend
MoveWindow(0,100)
ActivateWindow()
Return
Here is the .pbl file I used
Code: Select all
;
-framework Carbon
SetWindowAlpha 2
I'll be honest, I don't fully understand the OSX api stuff and have only
been using them with info I've been finding in this OSX forum.
Can anyone else try this, or look it over and see if I'm calling it wrong,
or if my .pbl file is incorrect?
Thanks,
-Garrett