Set File Icon?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
cmhjon
Posts: 175
Joined: Tue Aug 04, 2015 11:55 am

Set File Icon?

Post by cmhjon » Wed Jan 10, 2018 4:28 pm

Hello,

Is there a way to set the icon of a file (a Microsoft Word file) for example? After checking the dictionary, there doesn't seem to be a way to do this?

Thank you so much,
Jon :)

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Set File Icon?

Post by Klaus » Wed Jan 10, 2018 4:36 pm

Hi Jon,

if you mean OUTSIDE of LC, then you might be able to do this in LC via AppleScript on a Mac
and VBScript on WIndows, but not with the build-in means of LC.


Best

Klaus

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Set File Icon?

Post by bogs » Wed Jan 10, 2018 10:10 pm

I think it can be done inside Lc though, depending on the situation. If your trying for a system wide reset, then I believe Klaus is correct.

Inside Lc, you have to come up with a character to represent the icon you want to use, then set it in the field so it will look like this (field on left and menu button above) -
Image
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Set File Icon?

Post by jacque » Thu Jan 11, 2018 5:32 pm

Most operating systems use the file extension to determine the icon and the default app that will open the file. Name your file with a ".doc" extension and it should work. Of course, if the file isn't actually a Word file, MS Word won't be able to read it.

Or did you mean you want to show the icon inside a LC stack?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

cmhjon
Posts: 175
Joined: Tue Aug 04, 2015 11:55 am

Re: Set File Icon?

Post by cmhjon » Thu Jan 11, 2018 7:24 pm

Hi Jacque,

I am building an app that determines which version of an app a file was built with and then open said file with the appropriate app version (see viewtopic.php?f=7&t=30056).

I have all that working but because I have set several file types to open with my app, the icons of the files being opened with my app are changing to a generic file icon (which I am guessing is expected behavior) so I was trying to figure out a way to set the icon of said file back to the appropriate one.

Cheers,
Jon

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Set File Icon?

Post by jacque » Fri Jan 12, 2018 6:58 pm

So you're writing the file back to disk? There may be a shell call that will do it, since the user can assign a default app in the Get Info box in Finder, but I don't know what it might be. You may be able to find something with a Google search.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

cmhjon
Posts: 175
Joined: Tue Aug 04, 2015 11:55 am

Re: Set File Icon?

Post by cmhjon » Fri Jan 12, 2018 7:42 pm

Other than changing the icon of the file, my app makes no changes to the file whatsoever.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Set File Icon?

Post by jacque » Sat Jan 13, 2018 2:30 am

If you aren't saving the file then the icon shouldn't change. How are you opening it? Did you try opening for read-only?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

cmhjon
Posts: 175
Joined: Tue Aug 04, 2015 11:55 am

Re: Set File Icon?

Post by cmhjon » Wed Mar 07, 2018 7:40 pm

Hi Jacque,

My apologies for the very slow response. After changing the 'Open With' setting (in the Get Info dialog box) for the file types I have designed my app to work with, I just double-click one of files (of course, my app also has the necessary CFBundleTypeExtension info within it). My app opens for a split second and then the appropriate app version opens the file.

Example: I double-click an Adobe InDesign file. My app opens, determines the correct version of InDesign the file was built with, and then opens the corresponding version of InDesign (and my app quits).

Thank you,
Jon :)

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Set File Icon?

Post by jacque » Thu Mar 08, 2018 6:22 pm

I'm guessing this is a Finder thing. If you change the "open with" app, the next time the Finder opens the file, Finder tries to reset the icon. It doesn't see an appropriate one because the file extension doesn't match the LC extension so it uses a generic one.

I don't see a way around that unless you can find a shell command to reset the icon. It's a system thing, not a LC thing. I'm speculating though.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”