KeyPressed

Here is where the magnanimous folks that create externals post them (.zip archives only please).

KeyPressed

Postby codegreen » Sat Jul 28, 2012 7:50 pm

If there's a keystroke pending in the event queue, this XFcn will return the character it would type; otherwise it returns empty.

One optional Boolean parameter (tfDiscardKeystroke) controls whether the keystroke is flushed or left in the event queue. The default is false, meaning the keystroke isn't discarded.

HTH,
-Mark
Attachments
KeyPressed.bundle.zip
(6.9 KiB) Downloaded 282 times
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm

Re: KeyPressed

Postby wodehousefan » Mon Jul 30, 2012 8:21 am

Thank you very much for this! However, I cannot seem to import this bundle into my project (it keeps asking for the location of the file, or when I use SuperEdit 4.7 and try to import it, the bundle is greyed out in the filelist). How do you import this bundle into your projects?
wodehousefan
 
Posts: 8
Joined: Thu Jul 26, 2012 8:47 am

Re: KeyPressed

Postby codegreen » Mon Jul 30, 2012 6:37 pm

wodehousefan wrote:How do you import this bundle into your projects?

• Download the archive containing the XFcn bundle (KeyPressed.bundle.zip)

• Unzip the archive to create KeyPressed.bundle

• Launch SuperEdit and select 'Import Bundled External…' from the File menu

• Locate and select KeyPressed.bundle in the file open dialog that appears

A new project called KeyPressed.sc45 should be created containing the imported external. From there you can copy and paste it into whatever project you want.

HTH,
-Mark
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm

Re: KeyPressed

Postby wodehousefan » Tue Jul 31, 2012 8:29 am

Thank you! I was doing all the steps, except for the last. Rather than cutting and pasting the external within SuperEdit, I was trying to use the Resource Manager in SuperCard (which did not work).
KeyPressed is exactly what I was looking for. I haven't yet tried changing the default parameter yet.

Thanks again.
wodehousefan
 
Posts: 8
Joined: Thu Jul 26, 2012 8:47 am

Re: KeyPressed

Postby codegreen » Tue Jul 31, 2012 9:33 am

wodehousefan wrote:Rather than cutting and pasting the external within SuperEdit, I was trying to use the Resource Manager in SuperCard (which did not work).

It sounds as though you were mixing your metaphors (so to speak).

The Resource Manager's UI for importing bundled externals works a bit differently than SE's:

• Select 'Open…' from the popup above either list field and open the target project

• Select the Data Fork tab

• Click in the list field to activate it (it should hilite)

• From the center popup choose 'Import Bundle External'

• In the File Open dialog, locate and select KeyPressed.bundle

Basically a bundled external is just an external stored in a bundle wrapper. A bundle is a special type of folder which from the end user's perspective acts much like a file. When an external is created the compiler wraps this bundle around the raw executable, so all externals start life in bundles. It's possible to explicitly load externals directly from their bundles (and it's common to do so during debugging), but end users typically import them into the projects that use them to avoid dependencies and make them automatically available to calling scripts.

Once an external contained inside a bundle is imported it's no different than any other external, and (whether in SE or RM) you cut/copy/paste/delete it just like any other project resource.

HTH,
-Mark
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm

Re: KeyPressed

Postby wodehousefan » Tue Jul 31, 2012 10:23 am

Yes, I think I was. Your explanation is very useful. Thank you.
wodehousefan
 
Posts: 8
Joined: Thu Jul 26, 2012 8:47 am

Re: KeyPressed

Postby wodehousefan » Tue Jul 31, 2012 11:00 am

Sorry to bother you again, but I had one last question about the parameter (tfDiscardKeystroke). To change the value to TRUE, is an extra argument sent to KeyPressed? Or is that parameter a global that can be changed once and will maintain the value until it is changed again?
wodehousefan
 
Posts: 8
Joined: Thu Jul 26, 2012 8:47 am

Re: KeyPressed

Postby codegreen » Tue Jul 31, 2012 12:50 pm

wodehousefan wrote:Sorry to bother you again, but I had one last question about the parameter (tfDiscardKeystroke). To change the value to TRUE, is an extra argument sent to KeyPressed?

KeyPressed expects either zero or one parameters. Pass nothing or anything but "true" and the event is left in the queue.

-Mark
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm

Re: KeyPressed

Postby wodehousefan » Tue Jul 31, 2012 1:53 pm

Thanks! I that what I had assumed but wanted to check. Thanks again for all of your help, and for posting the external.
wodehousefan
 
Posts: 8
Joined: Thu Jul 26, 2012 8:47 am

Re: KeyPressed

Postby codegreen » Tue Jul 31, 2012 4:50 pm

You're welcome!
:D
-Mark
codegreen
 
Posts: 1517
Joined: Mon Jul 14, 2008 11:03 pm


Return to XCmds, XFcns, and XRtns

Who is online

Users browsing this forum: No registered users and 1 guest

cron