[futurebasic] Re: [FB] FBtoC Copy and Paste in Nib Window Fields

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2008 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Sun, 16 Mar 2008 22:03:07 +1300
Rich Love wrote:

> I am having a problem with copying and pasting text in edit fields.
> It works perfect in FB but does strange things in FBtoC.

This 'interesting' bug can be reproduced under closely controlled  
conditions. It occurs only if all 3 conditions below are true:
[1] Cut/Copy/Paste menu items have the appropriate HICommands
[2] event handling is done with a plain HandleEvents loop
[3] the FBtoC-translated app is run on OS X 10.5

'-----------------
/*
Demo shows edit malfunction when built with FBtoC and run in 10.5.
Cut/Copy/Paste menu items not enabled correctly and don't work.
Cmd-X, Cmd-C, Cmd-V don't work.
(Some may work once before stopping).
*/
edit menu 2
call SetMenuItemCommandID( fn GetMenuHandle( 2 ), 4, _kHICommandCut )
call SetMenuItemCommandID( fn GetMenuHandle( 2 ), 5, _kHICommandCopy )
call SetMenuItemCommandID( fn GetMenuHandle( 2 ), 6, _kHICommandPaste )
window 1
dim as Rect r
SetRect( @r, 20, 20, 200, 40 )
appearance button 1,,,,,, @r, _kControlEditUnicodeTextProc
do
HandleEvents
until ( gFBQuit )
'-----------------

Workaround 1
Use RunApplicationEventLoop() instead of polling with HandleEvents.
(FB code must be fully CarbonEvent-driven).

Workaround 2
Event polling sucks, has been deprecated since OS X 10.0, and can be  
avoided easily by preceding the HandleEvents loop with:
   poke long event - 8, 0xFFFFFFFF // no null events, thanks
(Scummy old FB code, especially PG, may *require* polling).

Workaround 3
Remove Command from menu items Cut/Copy/Paste (set <no command> in IB).
Then Cmd-X, Cmd-C, Cmd-V work, but
   Cut/Copy/Paste don't work if chosen from the edit menu; Cut/Copy/ 
Paste are enabled all the time.
(Users may not notice the residual bugs).

Robert P.