New m1 troubles in code

Usually, when a project access to the hard disk (for images), macOS ask for permissions. But not this time.

The process runs in three times:
a. drop a folder onto a Canvas
b. press the Process pushbutton (look below)
the code scan the dropped folder contents, generate a valid html “file” stored in a TextArea;
c. That data can be saved to disk (Save As HTML PushButton)…

d. Rendered immediately: press the Render HTML PushButton in a nw window using an HTMLViewer.
The html links some images (.images/.png).
I also have an icon “To the Top” with each image.

I have a SelectFolder that ask me to choose the images location.

None of these are displayed; macOS ask me nothing.

Once saved, the TA contents (html file) works fine with any browser.

That project works fine with an MacBook Pro i5 / IDE and application.

Rendered screen shot (atom)

Big Sur /M1:
Format(Item_Size, “## ###,###”)
Does not display the integert formatted as intended…
Works fine with the i5.

So a html file you load into HTMLViewer doesn’t show pictures?
How are those pictures referenced?

What OS you running on the i5? These days you have to ask permission to load local images for display. Even in Mojave.

Christian:
the html file is working fine when loaded in Firefox (or Safari).
I pass the TextArea.Text contents to the HTMLViewer.

Tim:
With the i5, the project works fine; the images appeared.

i5:
El Capitan / High Sierra
Xojo 2015r1.

M1: it does not ask for permissions (running in the IDE). This is probably because I use SelectFolder to get the images folder; then I load each image by name: Images_FI.Child("image1.png")


// Ask the user to choose the images folder
Data_FI = SelectFolder()

// Renders the document
wRender.HTMLViewer1.LoadPage(TA.Text, Data_FI)

but the files are not loaded.

No, Big Sur doesn’t ask, it just makes the HTMLViewer unable to load local images.

To solve this requires a method (using Declares) that came to me from @Sam_Rowlands but you should ask him if I can pass it to you.

1 Like

I posted the declares somewhere, but you now need to ask the OS for permissions to display local HTML content.

Emile, have a look at the link in Sam’s post above, it shows the required code. You would call it as:


wRender.HTMLViewer1.grantAccessToFolder (Data_FI.Parent)

(pretty sure you need the .Parent business.)

I must say I’m not sure why Apple or anyone might think that this has added extra, useful, security to macOS. Someone who knows how has added some Declares and - voila - we are back to where we were previously. :thinking:

1 Like

See also WKWebViewMBS class in MBS Xojo Plugins.

we have:

LoadFileURL(File as FolderItem, readAccessItem as FolderItem)

and you can put in the folder for the images there.

IT WORKS !

Thank you to Sam, Tim, Christian.

To the Xojo people:
When will you add a “Big Sur” Special Page with tips and tricks to run Xojo projects with “Big Sur” ?
(Next: do the same with “Monterey”)

PS: it is possible that I read that thread last year, but I have troubles to recall if I took my pills this morning, so remembering what I read one year ago is beyond… !

2 Likes