Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 18.4 ('Mac to iOS')
Instant purchase and download via GumRoad!

COLUMN

Fixing Drag and Drop

Freeing up the Finder

Issue: 18.4 (July/August 2020)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 10,112
Starting Page Number: 76
Article Number: 18407
Resource File(s):

Download Icon project18407.zip Updated: 2020-07-01 11:02:02

Related Link(s): None

Excerpt of article text...

I have several utility programs I use regularly to manipulate files. These do things like convert the content from one format to another, fix issues with the content, or rename files. The common trait is that these all work on files via drag and drop. I drag files to my program and it does its work on them.

In general this has worked great for many years. However, I recently worked on several projects where the processing of the files was complicated enough to take some time (10+ seconds) and the number of files was large (100+). That's when I noticed something odd.

Even though I'd successfully dragged files from the macOS Finder to the application and it had begun processing them, the app did not release control back to the Finder right away. There was a considerable pause—sometimes minutes long—where the Finder wouldn't respond, showing me a beachball cursor, which lasted until either my app finished processing the files or a timeout occurred.

Needless to say, this was annoying. I knew the file processing would take time and I didn't care about that, but I wanted to be able to do other things while I waited—and I couldn't.

This puzzled me because I hadn't seen this behavior before. Was it new or had it always been this way? It only happened when the conversion task was lengthy, but when it did it was really annoying. I couldn't just drag files and go on and do something else—the Finder was effectively frozen until my application released the drag and drop.

This concept is tricky to describe, so it's best to see if for yourself (see Figure 1). Run today's demo project and drop some files onto the top drop area ("Slow Drop"). This will simulate a slow conversion process (nothing will actually be done to the dropped files, so it doesn't matter which ones you drop into the app) and show the problem.

...End of Excerpt. Please purchase the magazine to read the full article.