Dashcode newbie question

Discussion in 'Mac Programming' started by sOwL, Jan 24, 2011.

  1. sOwL macrumors 6502

    sOwL

    Joined:
    Sep 25, 2007
    Location:
    Nerd Cave
    #1
    Hello, im creating my first dashboard widget and i need a tiny bit of help. I've created a widget that will run an application when you drop a file on it. How can i have that application actually use that file, as if i dropped it on its icon on the dock? Searched a lot but couldnt find any answer on this
     
  2. sOwL thread starter macrumors 6502

    sOwL

    Joined:
    Sep 25, 2007
    Location:
    Nerd Cave
    #2
    Hmm im getting no replies so i'll try to be more specific:

    Using the code snippet for drag and drop that Dashcode has, i'm retreiving the path to the file im dragging in text form. This is saved in 'uriList'. Ive tested an alert and it gets the correct value. So, ondrop, my code saves that path to 'uriList' and also opens an application. How can i 'send' that path to the application being opened so it can use it as if i droped the file on that application on first place?

    Wow im surprised that none knows this yet, it seemed simple to me but yet i just cant find info on how to do it.
     
  3. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #3
    It might help if you could post more about how you are launching the application now. Is it a web application? Is it a Mac OS X .app bundle? Is it a command line (unix) executable....

    B
     
  4. sOwL, Jan 25, 2011
    Last edited by a moderator: Jan 25, 2011

    sOwL thread starter macrumors 6502

    sOwL

    Joined:
    Sep 25, 2007
    Location:
    Nerd Cave
    #4
    No, its a widget.

    Code:
            var applicationIdentifier = "com.xx.yy";
            widget.openApplication(applicationIdentifier);
            widget.openURL(uriString);
    
    That little piece of code opens the application i want, and runs the file ive droped on my widget at the same time. (uriString is moreover the same with uriList, uriList is jsut meant for if i drop more than one files). So the application that gets opened, i want it to actually use uriString. Any ideas?

    EDIT:

    Hmm i'm starting to get a little worried about this... So many views yet still no replies.. Am i doing something tottaly wrong? Would i need to use more than just Javascript to achieve what i'm trying to? Because i've seen many widgets having that sort of functionality, one would imagine that it would be easy enough to do on dashcode... So how would you guys do it if you wanted to? Would you use c++ for example? And could i include c++ scripts in a widget??
     
  5. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #5
    See here:
    http://developer.apple.com/library/...board_ProgTopics/Articles/ExternalAccess.html

    Scroll to bottom of page and read:
    Note that there is no facility for passing arguments to an application. For this level of interactivity between a widget and application, you could try one of these options:
    • Use the widget.system() method, as discussed in “Accessing Command Line Utilities,” with the open command-line utility
    • Implement a widget plug-in, as discussed in “Creating a Widget Plug-in”

    If you've seen widgets with this functionality, why don't you get one and look at how it does it?
     
  6. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #6
    Yeah, I was thinking that you could possibly write out and call an AppleScript "wrapper" that would call your app with the argument, but was looking for the docs that chown33 found before saying anything.

    B
     
  7. sOwL thread starter macrumors 6502

    sOwL

    Joined:
    Sep 25, 2007
    Location:
    Nerd Cave
    #7
    Wow thank you, i missed that one. And i have, but still couldn't understand what's going on in the code. Never used javascript for anything other than web developing so i got kinda confused... Also to any moderator that merged my posts, sorry i'll try not to double post next time :)
     
  8. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #8
    Post links and/or code you don't understand here. Maybe someone can explain it.

    B
     
  9. sOwL thread starter macrumors 6502

    sOwL

    Joined:
    Sep 25, 2007
    Location:
    Nerd Cave
    #9
    Will do. Thanx for taking the time to help me man, much appreciated
     

Share This Page