image ResEx Logo
ResExcellence www : Powered by Google
Cell Phone Themes Icons Mighty Mouse Cursors Software Reviews Widgets & Widgets

Articles
   3D
   Audio
   Custom Controls
   General RB
   Graphics
   Hacks
   Mac OS X
   Menus
   Novelty
   Printing
   REALbasic 2005
   REALbasic 2006
   Registration
   Resources
   Reviews
   Serial
   Speech
   Sockets
   XML
   Video
Resource Links
News
   Current News
   February 2006
   January 2006
   December 2005
   November 2005
   October 2005
   September 2005
   August 2005
   July 2005
   June 2005
   May 2005
   April 2005
   March 2005









REALbasic for Dummies
by Erick Tejkowski


Learning REALbasic through Applications
by Clayton E., Crooks II


REALbasic for Macintosh
by Michael Swaine


REALbasic Cross-Platform Application Development
by Mark S. Choate





Older files are in Stuffit 5 or greater format. Newer files are ".Zip". Download StuffIt Expander
Tell us about a bad link. Thank You!

Spotlight Integration Take 1 by Seth Willits
August 13, 2005

Printer Version




Using New Features From REALbasic 2005!
In this tutorial, we're going to primarily use a new feature from REALbasic 2005 which is the new integration with Spotlight in Mac OS X 10.4. Spotlight is a very advanced beast and REALbasic's implementation of the feature is simple and easy to use (though it has it's annoying quirks [that almost make it useless] as you'll see). We'll take a look at how to use it as well as a neat little trick that displays the Spotlight window in your app.



SpotlightQuery Class
This is the heart of the integration. All you have to do is create an instance, set the Query property, and call the Run method. Voila! What happens next is the Changed event is called several times which signals that results have been added, removed, or somehow changed. I don't want to go into too much detail with a good project yet, because I'm extremely unsatisfied with the results I've come up with. It takes 1 second for Spotlight to find 22,000 files on my hard drive, but it takes REALbasic's ListBox 11.7 seconds to display the results (during which the application is completely locked up). If I try to display them live (as they come in) it takes an utterly ridiculous 6+ minutes! As I'm sure you can understand, this is completely unacceptable, and I'm still trying to find a decent answer to this.


The Code
So for now, let's just experiment with this:

SpotlightQuery1.Query = "kMDItemContentType = ""*audio*"""
SpotlightQuery1.Synchronous = true
SpotlightQuery1.Run

LBResults.DeleteAllRows
for i as Integer = SpotlightQuery1.Count - 1 DownTo 0
  LBResults.AddRow SpotlightQuery1.Item(i).File.Name
  LBResults.CellTag(LBResults.LastIndex, 0) = SpotlightQuery1.Item(i).File
next


Pretty short, no? Well, have fun waiting for those 22,000 results to show up. In the mean time, here's a cool tip:



Spotlight Results Window
Now check this out:

Sub Action()
  dim resultCode as Integer
  Declare Function HISearchWindowShow Lib "Carbon" (SearchStr as CFStringRef, Options as Integer) as Integer
  
  resultCode = HISearchWindowShow("bear", 0)
  if resultCode <> 0 then
    beep
  end if
End Sub

Eh? Eh?? How cool is that?! Essentially one line of code and magically your application has a REAL Spotlight window! I thought that was the coolest thing since sliced bread when I found it.


Finished
As always, you can download the project here.




Cell Phone Themes Icons Mighty Mouse Cursors Software Reviews Widgets & Widgets

Maintained by the Staff of ResExcellence. This entire site ©1997-2006 ResExcellence
Privacy Statement? Sure we gotta Privacy Statement. [an error occurred while processing this directive]