Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS MacOSX Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacOSX/Loginitems
This example is the version from Sun, 17th Mar 2012.
Project "Loginitems.xojo_binary_project"
FileTypes
Filetype application
Filetype folder
End FileTypes
Class Window1 Inherits Window
Control info Inherits Label
ControlInstance info Inherits Label
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Sub DropObject(obj As DragItem, action As Integer)
dim f as FolderItem
do
if obj.FolderItemAvailable then
f=obj.FolderItem
if Keyboard.AsyncOptionKey then
delete f
else
add f
end if
end if
loop until not obj.NextItem
End EventHandler
EventHandler Function KeyDown(key As String) As Boolean
dim n as integer
if (asc(key)=8 or asc(key)=127) and list.listindex>=0 then
n=me.CellTag(list.listindex,0) //get id from invisible column
if l.Remove(n) then
update
else
msgBox "Error on removing the login item."
end if
end if
End EventHandler
EventHandler Sub Open()
me.AcceptFileDrop "application"
me.AcceptFileDrop "folder"
End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
EventHandler Sub Activate()
update
End EventHandler
Protected Sub add(f as folderitem)
if l.AddFile(f) then
update
else
MsgBox "Failed to add item."
end if
End Sub
Protected Sub delete(f as folderitem)
if l.RemoveFile(f) then
update
else
MsgBox "Failed to add item."
end if
End Sub
Sub update()
dim i as integer
dim c as integer
dim file as FolderItem
dim hide as Boolean
dim url as string
l=new LoginItemsMBS
List.DeleteAllRows
info.text=str(l.count)+" Login items found for this user."
c=l.count-1
for i=0 to c
hide=l.IsHidden(i)
url=l.URL(i)
file=l.File(i)
if file=nil then // some items which don't exist?
list.addrow "?"
if hide then
list.cell(list.lastIndex,1)="hide"
else
list.cell(list.lastIndex,1)=""
end if
list.cell(list.lastIndex,2)=url
List.CellTag(list.lastIndex,0)=i
else
list.addrow file.DisplayName
if hide then
list.cell(list.lastIndex,1)="hide"
else
list.cell(list.lastIndex,1)=""
end if
list.cell(list.lastIndex,2)=url
List.CellTag(list.lastIndex,0)=i
end if
next
End Sub
Property Protected l As loginItemsMBS
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
End Project
The items on this page are in the following plugins: MBS MacOSX Plugin.