Replacement for MBS IconFamilyMBS functionality

  1. 2 weeks ago

    Tim J

    Feb 6 Pre-Release Testers, Xojo Pro Dehydrating in AZ

    I know that this has been discussed before, but the IconFamilyMBS is now gone and I'm looking for the proper replacement logic for this code that pulls the icon for a provided file extension:

    i = New IconMBS("", "", theExtension, "")
    WMain.lbRestorePaths.RowPicture(WMain.lbRestorePaths.LastIndex) = i.IconFamily.Icon(26)

    @ChristianSchmitz ?

  2. Christian S

    Feb 6 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    FolderItem.IconMBS could do it.

  3. Tim J

    Feb 6 Pre-Release Testers, Xojo Pro Dehydrating in AZ

    For a family type? In other words, I may not have a handle to an actual file, but I want to display the icon that the user's system would normally assign to a file of the type defined by the extension provided.

    IconFamily allowed that.

  4. Christian S

    Feb 6 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    NSWorkspaceMBS.IconMBS gives a NSImageMBS object. You can use setSize to change size and copyPicture to get pictures for each size.

    The NSImageMBS contains several resolutions.

  5. Tim J

    Feb 7 Pre-Release Testers, Xojo Pro Dehydrating in AZ

    It's not the resolution that I'm looking for, but rather a way to retrieve the general icon for a "type" of file. In the above code, I'm getting the macOS generic "App" icon and I don't have a folderitem to pass in. What I was doing with the older IconFamily code was getting the general icon for a family type rather than a specific file. Much the same as what you have provided with the new LinuxIconMBS.SymbolicIcon("application/vim", 22) function.

  6. Tim J

    Feb 7 Pre-Release Testers, Xojo Pro Dehydrating in AZ

    Ah - I've now found the NSWorkSpaceMBS.IconForFileType() function.

    Does the "filetype" passed need to be part of the project's FileTypes definition file or does passing something like "zip" as the extension work?

  7. Christian S

    Feb 7 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    Any type will work :-)

  8. Tim J

    Feb 8 Pre-Release Testers, Xojo Pro Dehydrating in AZ
    Edited 2 weeks ago

    I found the online docs for this and noted the discussion of the type.

    Is this the correct code for retrieving a generic App icon and creating a 22x22 icon that supports the @1 and @2 sizes when the HiDPI is on?

    Dim iconImage As NSImageMBS
    Dim iconPic As Picture
    
    iconImage = NSWorkspaceMBS.iconForFileType("app")
    iconImage.setSize(44, 44)
    iconPic = iconImage.CopyPictureWithMask
    iconPic.VerticalResolution = 144
    iconPic.HorizontalResolution = 144
    
    GenericApp = iconPic

    Or - is this an equivalent?

    Dim i As New NSImageMBS 
    i = NSWorkspaceMBS.iconForFileType("fcpbundle")
    Me.RowPicture(Me.LastIndex) = i.CopyPictureWithMask.ScaleImageAndMaskMBS(22, 22, True)

    Both seem to work.

  9. Christian S

    Feb 8 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    With CopyPictureWithMask, you get a Xojo picture with 44 pixel width/height here.
    So this sounds okay if you like a 2x picture.

or Sign Up to reply!