#!/usr/bin/perl -w # # Copyright 2000 by Michael Coyle # Released under GPL. # # Call it with: # [an error occurred while processing this directive] # # Get the file name from the browser... $file_name = $ENV{'QUERY_STRING'}; # Open the file... open (EP, $file_name); # Print to the browser... print "Content-Type: text/html \n\n"; # Load the file and keep spitting it out to the browser... while () { chomp; print "$_ "; } # Close the file and go home... close EP #!/usr/bin/perl -w # # Copyright 2000 by Michael Coyle # Released under GPL. # # Call it with: # [an error occurred while processing this directive] # # Get the file name from the browser... $file_name = $ENV{'QUERY_STRING'}; # Open the file... open (EP, $file_name); # Print to the browser... print "Content-Type: text/html \n\n"; # Load the file and keep spitting it out to the browser... while () { chomp; print "$_ "; } # Close the file and go home... close EP

3D
3D Photo Gallery (Part 1)
3D Photo Gallery (Part 2)

Audio
Poor Man's MIDI
Make A Metronome
iPod Tricks (Part 1)
iPod Tricks (Part 2)
iPod Tricks (Part 3)
Laugh Track Machine
Audio Player with Reverb
Shepard Melody
RB Phone Home
Build a Drum Machine

Custom Controls and Windows
Double Click Listbox
Draggable Metal Window
Double Click Canvas
Custom Buttons
Custom Buttons Part II
iTunes-style Listboxes
Custom Controls


General RB
Scrolling Windows
Using Mesage Dialogs
Case-Sensitive Word Finder
Introduction to Stacks
Wiggle Window
JPEG in PDF
Listbox Checkboxes
Background Applications
Listbox Auto-Find
Virtual Volumes
Time Tracker
Software Distribution (Part 1)
Software Distribution (Part 2)
Software Distribution (Part 3)
Software Distribution (Part 4)
Exceptions
Tips and Tricks
Text Clippings Made Easy

Graphics
Drawing a Simple Gradient
The SpriteSurface: Space Game
Image Spinner
Cropping Graphics (Part 1)
Cropping Graphics (Part 2)
Cropping Graphics (Part 3)
Cropping Graphics (Part 4)
Shimmer Graphics
Lissajous Figures
Simple Screen Capture
Vector Graphics
Kaleidoscope Images
Stegonography
Spirals!
Image Table
RB Magnifying Lens
Screen Capture
Color Picker Tutorial

Hacks
Ghost Grab
Speedy Mouse Extension
iTunes Plugins
iTunes Skinner

Mac OS X
Global Hot Key Event (Carbon Events)
Login Welcomer (Carbon Events)
Add/Remove Buttons
Resizable Sheets
Mac OS X Preferences Window
Using Sheets in REALbasic
Build a Bundle (Part 1)
Build a Bundle (Part 2)
Dock Your Passwords
Mac OS X Debugging
REALbasic Mac OS X Icon Tutorial
Animate Your Dock
RB and the Command Line

Menus
Window Menu
Templates Menu
Listbox Menu

Novelty
Guessing Game
Calendar Trivia
Tile Mixer
Zip Code Finder
Happy Valentine's Day
Merlin Simulator (Part 1)
Merlin Simulator (Part 2)
Merlin Simulator (Part 3)
Buzzword Machine
AppleSoft BASIC

Printing
Print to PDF

Registration
Registration Code Validation
Network Registration Codes

Resources
Picture Extractor (Part 1)
Picture Extractor (Part 2)

Serial
Caller ID (Part 1)
Caller ID (Part 2)
Caller ID (Part 3)

Speech
Speech Recognition

Socket Communication
Easy Peer-to-Peer File Sharing
MacPAD Version Checking
Display Web Image In Canvas
HTML IMG Tags
Version Tracking
Even Smarter Instant Messaging
Web Tiler
JavaScript and REALbasic
Stock Ticker (Part I)
Stock Ticker (Part 2)
AIM Mate

XML Manipulation
Simple XML Introduction

Video
Big Brother Video Capture

Note: All articles without a byline were written by Erick Tejkowski. When cleaning the site I removed them because the code differed from page to page, and I have yet to put them back in.

resexc2.gif (20k)

   




REALbasic for Dummies
by Erick Tejkowski

$19.99 @ Amazon





Files are in Stuffit 6.5 or earlier, or ZIP format.
Download Stuffit Expander

Tell us about a bad link.

DoubleClickListbox by Seth Willits
06-05-04




DoubleClickListbox
I started writing an application today, a database viewer program for REAL Databases in v5.5, and I found myself looking back to my own tutorials for help! One of the classes I needed in my program was a Listbox that allowed me to double click on a cell and be notified of it. I was a little startled to see that there wasn't a tutorial for this, so I've decided to write one. The code in this class is based on that from the DoubleClickCanvas class, so you can see that tutorial for more information. The only real difference is I've updated it a bit for v5.5 to incluce Mach-O and (limited) Linux compatibility, but it's still the same simple principle.

Setup
Start out by creating a new Listbox subclass, DoubleClickCanvas. Next, create the three properties shown in the image below, as well as create the events listed here:

  • Open
  • CellClick(row as integer, column as integer, x as integer, y as integer) as Boolean
  • CellDoubleClick(row as integer, column as integer)

The Open Event
Well as you can see, the Open event is pretty simple. We simply set the two variables which are keeping track of the cell last clicked on (mLastClickRow and mLastClickColumn) to -1 in order to signify that no cell has been clicked yet, then we call the Open event of our subclass or instance, whichever it happens to be.

The CellClick Event
This is where all of the magic happens. The majority of the code is simply setting up Declares to get the users' specified double click time in ticks. On the Mac, GetDblTime returns the maximum number of ticks that can pass between double clicks, on Windows it returns milliseconds so we convert it to ticks, and on Linux, well I'm not sure what the Declare is so I cheated and used 30.

Function CellClick(row as Integer, column as Integer, x as Integer, y as Integer) As Boolean
   dim doubleClickTime as Integer
   
   #if TargetCarbon then
      #if TargetMachO then
         Declare Function GetDblTime Lib "Carbon" () as Integer
      #else
         Declare Function GetDblTime Lib "CarbonLib" () as Integer
      #endif
      doubleClickTime = GetDblTime()
   #else
      #if TargetMacOS then
         Declare Function GetDblTime Lib "InterfaceLib" () as Integer
         doubleClickTime = GetDblTime()
      #endif
   #endif
   #if TargetWin32 then
      Declare Function GetDoubleClickTime Lib "User32.DLL" () as Integer
      doubleClickTime = GetDoubleClickTime() / 1000 * 60
   #endif
   #if TargetLinux then
      doubleClickTime = 30 //???
   #endif



And below, here we deterine a) whether the difference in time between the two clicks is within the maximum limit of a valid double click, and b) whether the last click and the current click were clicks on the same cell. If they were, we just call the CellDoubleClick event.

   
   // If the two clicks happened close enough together in time
   if ((Ticks - mLastClickTicks) <= doubleClickTime) and (row = mLastClickRow) and (column = mLastClickColumn) then
      CellDoubleClick row, column
   end if
   mLastClickTicks = Ticks
   mLastClickRow = row
   mLastClickColumn = column
End Function



After that, we reset the current click time and cell clicked.

Finished
So that's it. It works like a charm. The most often use of this is probably to allow editing of a cell when it is double clicked. Rather than setting the cell or column type to "3" (editable), you can leave the cell selectable, but when it is double clicked, use Listbox.EditCell(row, column) in the CellDoubleClick event to make the cell editable. I hope you find a use for this; I know I have! As always, you can download the project here.






Please support ResExcellence by Visiting our Sponsors. One click makes a difference.


Download REALbasic and create your own software!

#!/usr/bin/perl -w # # Copyright 2000 by Michael Coyle # Released under GPL. # # Call it with: # [an error occurred while processing this directive] # # Get the file name from the browser... $file_name = $ENV{'QUERY_STRING'}; # Open the file... open (EP, $file_name); # Print to the browser... print "Content-Type: text/html \n\n"; # Load the file and keep spitting it out to the browser... while () { chomp; print "$_ "; } # Close the file and go home... close EP #!/usr/bin/perl -w # # Copyright 2000 by Michael Coyle # Released under GPL. # # Call it with: # [an error occurred while processing this directive] # # Get the file name from the browser... $file_name = $ENV{'QUERY_STRING'}; # Open the file... open (EP, $file_name); # Print to the browser... print "Content-Type: text/html \n\n"; # Load the file and keep spitting it out to the browser... while () { chomp; print "$_ "; } # Close the file and go home... close EP