Page 1 of 1

Re: Overcoming limitation browsing for .app files

Posted: Wed Feb 29, 2012 9:18 pm
by Shardik
You may try this workaround to display a list of apps. After you double click
onto an app it will be started:

Code: Select all

OpenWindow(0, 270, 100, 270, 170, "Double click on app to start it")
ListViewGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20)

If ExamineDirectory(0, "/Applications", "")
  While NextDirectoryEntry(0)
    If DirectoryEntryType(0) = #PB_DirectoryEntry_Directory
      If LCase(Right(DirectoryEntryName(0), 4)) = ".app"
        AddGadgetItem(0, -1, DirectoryEntryName(0))
      EndIf
    EndIf
  Wend
EndIf

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      If EventGadget() = 0
        If EventType() = #PB_EventType_LeftDoubleClick
          RunProgram("Open", "/Applications/" + GetGadgetText(0), "", #PB_Program_Open)
        EndIf
      EndIf
  EndSelect
ForEver
Another workaround would be to utilize the ExplorerTreeGadget (if you don't
mind double clicking onto the virtual app folder to start the app):

Code: Select all

OpenWindow(0, 270, 100, 270, 270, "Double click on app to start it")
ExplorerTreeGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 20, "/Applications/")

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      If EventGadget() = 0
        If EventType() = #PB_EventType_LeftDoubleClick
          RunProgram("Open", GetGadgetText(0), "", #PB_Program_Open)
        EndIf
      EndIf
  EndSelect
ForEver

Re: Overcoming limitation browsing for .app files

Posted: Thu Mar 01, 2012 1:05 pm
by P-J
Thanks for the suggestion above. I'll certainly give it a go.

I was hoping to have seamless cross-platform functionality (using native file browsers), but if this works it'll certainly do for now!