|
|
|
@@ -382,7 +382,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
|
|
|
|
|
|
|
|
|
case kEventControlGetClickActivation :
|
|
|
|
|
{
|
|
|
|
|
// fix to always have a proper activation for DataBrowser controls (stay in bkgnd otherwise)
|
|
|
|
|
// fix to always have a proper activation for DataBrowser controls (stay in bkgnd otherwise)
|
|
|
|
|
WindowRef owner = cEvent.GetParameter<WindowRef>(kEventParamWindowRef);
|
|
|
|
|
if ( !IsWindowActive(owner) )
|
|
|
|
|
{
|
|
|
|
@@ -451,12 +451,12 @@ static pascal OSStatus wxMacWindowServiceEventHandler( EventHandlerCallRef handl
|
|
|
|
|
textCtrl->GetSelection( &from , &to ) ;
|
|
|
|
|
wxString val = textCtrl->GetValue() ;
|
|
|
|
|
val = val.Mid( from , to - from ) ;
|
|
|
|
|
PasteboardRef pasteboard = cEvent.GetParameter<PasteboardRef>( kEventParamPasteboardRef, typePasteboardRef );
|
|
|
|
|
PasteboardRef pasteboard = cEvent.GetParameter<PasteboardRef>( kEventParamPasteboardRef, typePasteboardRef );
|
|
|
|
|
verify_noerr( PasteboardClear( pasteboard ) ) ;
|
|
|
|
|
PasteboardSynchronize( pasteboard );
|
|
|
|
|
CFDataRef data = CFDataCreate( kCFAllocatorDefault, (UInt8*)val.c_str(), val.length() );
|
|
|
|
|
PasteboardPutItemFlavor( pasteboard, (PasteboardItemID) 1, CFSTR("com.apple.traditional-mac-plain-text"), data, 0);
|
|
|
|
|
CFRelease( data );
|
|
|
|
|
PasteboardSynchronize( pasteboard );
|
|
|
|
|
CFDataRef data = CFDataCreate( kCFAllocatorDefault, (UInt8*)val.c_str(), val.length() );
|
|
|
|
|
PasteboardPutItemFlavor( pasteboard, (PasteboardItemID) 1, CFSTR("com.apple.traditional-mac-plain-text"), data, 0);
|
|
|
|
|
CFRelease( data );
|
|
|
|
|
result = noErr ;
|
|
|
|
|
}
|
|
|
|
|
break ;
|
|
|
|
@@ -464,34 +464,34 @@ static pascal OSStatus wxMacWindowServiceEventHandler( EventHandlerCallRef handl
|
|
|
|
|
case kEventServicePaste :
|
|
|
|
|
if ( textCtrl )
|
|
|
|
|
{
|
|
|
|
|
PasteboardRef pasteboard = cEvent.GetParameter<PasteboardRef>( kEventParamPasteboardRef, typePasteboardRef );
|
|
|
|
|
PasteboardSynchronize( pasteboard );
|
|
|
|
|
ItemCount itemCount;
|
|
|
|
|
verify_noerr( PasteboardGetItemCount( pasteboard, &itemCount ) );
|
|
|
|
|
for( UInt32 itemIndex = 1; itemIndex <= itemCount; itemIndex++ )
|
|
|
|
|
{
|
|
|
|
|
PasteboardItemID itemID;
|
|
|
|
|
if ( PasteboardGetItemIdentifier( pasteboard, itemIndex, &itemID ) == noErr )
|
|
|
|
|
{
|
|
|
|
|
CFDataRef flavorData = NULL;
|
|
|
|
|
if ( PasteboardCopyItemFlavorData( pasteboard, itemID, CFSTR("com.apple.traditional-mac-plain-text"), &flavorData ) == noErr )
|
|
|
|
|
{
|
|
|
|
|
CFIndex flavorDataSize = CFDataGetLength( flavorData );
|
|
|
|
|
char *content = new char[flavorDataSize+1] ;
|
|
|
|
|
memcpy( content, CFDataGetBytePtr( flavorData ), flavorDataSize );
|
|
|
|
|
content[flavorDataSize]=0;
|
|
|
|
|
CFRelease( flavorData );
|
|
|
|
|
PasteboardRef pasteboard = cEvent.GetParameter<PasteboardRef>( kEventParamPasteboardRef, typePasteboardRef );
|
|
|
|
|
PasteboardSynchronize( pasteboard );
|
|
|
|
|
ItemCount itemCount;
|
|
|
|
|
verify_noerr( PasteboardGetItemCount( pasteboard, &itemCount ) );
|
|
|
|
|
for( UInt32 itemIndex = 1; itemIndex <= itemCount; itemIndex++ )
|
|
|
|
|
{
|
|
|
|
|
PasteboardItemID itemID;
|
|
|
|
|
if ( PasteboardGetItemIdentifier( pasteboard, itemIndex, &itemID ) == noErr )
|
|
|
|
|
{
|
|
|
|
|
CFDataRef flavorData = NULL;
|
|
|
|
|
if ( PasteboardCopyItemFlavorData( pasteboard, itemID, CFSTR("com.apple.traditional-mac-plain-text"), &flavorData ) == noErr )
|
|
|
|
|
{
|
|
|
|
|
CFIndex flavorDataSize = CFDataGetLength( flavorData );
|
|
|
|
|
char *content = new char[flavorDataSize+1] ;
|
|
|
|
|
memcpy( content, CFDataGetBytePtr( flavorData ), flavorDataSize );
|
|
|
|
|
content[flavorDataSize]=0;
|
|
|
|
|
CFRelease( flavorData );
|
|
|
|
|
#if wxUSE_UNICODE
|
|
|
|
|
textCtrl->WriteText( wxString( content , wxConvLocal ) );
|
|
|
|
|
textCtrl->WriteText( wxString( content , wxConvLocal ) );
|
|
|
|
|
#else
|
|
|
|
|
textCtrl->WriteText( wxString( content ) ) ;
|
|
|
|
|
textCtrl->WriteText( wxString( content ) ) ;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
delete[] content ;
|
|
|
|
|
result = noErr ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
delete[] content ;
|
|
|
|
|
result = noErr ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break ;
|
|
|
|
|
|
|
|
|
@@ -529,7 +529,7 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even
|
|
|
|
|
charBuf[ numChars - 1 ] = 0;
|
|
|
|
|
#if SIZEOF_WCHAR_T == 2
|
|
|
|
|
uniChars = (wchar_t*) charBuf ;
|
|
|
|
|
/* memcpy( uniChars , charBuf , numChars * 2 ) ;*/ // is there any point in copying charBuf over itself? (in fact, memcpy isn't even guaranteed to work correctly if the source and destination ranges overlap...)
|
|
|
|
|
/* memcpy( uniChars , charBuf , numChars * 2 ) ;*/ // is there any point in copying charBuf over itself? (in fact, memcpy isn't even guaranteed to work correctly if the source and destination ranges overlap...)
|
|
|
|
|
#else
|
|
|
|
|
// the resulting string will never have more chars than the utf16 version, so this is safe
|
|
|
|
|
wxMBConvUTF16 converter ;
|
|
|
|
@@ -551,29 +551,29 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even
|
|
|
|
|
|
|
|
|
|
UInt32 message = uniChars[pos] < 128 ? (char)uniChars[pos] : '?';
|
|
|
|
|
/*
|
|
|
|
|
NB: faking a charcode here is problematic. The kEventTextInputUpdateActiveInputArea event is sent
|
|
|
|
|
multiple times to update the active range during inline input, so this handler will often receive
|
|
|
|
|
uncommited text, which should usually not trigger side effects. It might be a good idea to check the
|
|
|
|
|
kEventParamTextInputSendFixLen parameter and verify if input is being confirmed (see CarbonEvents.h).
|
|
|
|
|
On the other hand, it can be useful for some applications to react to uncommitted text (for example,
|
|
|
|
|
to update a status display), as long as it does not disrupt the inline input session. Ideally, wx
|
|
|
|
|
should add new event types to support advanced text input. For now, I would keep things as they are.
|
|
|
|
|
NB: faking a charcode here is problematic. The kEventTextInputUpdateActiveInputArea event is sent
|
|
|
|
|
multiple times to update the active range during inline input, so this handler will often receive
|
|
|
|
|
uncommited text, which should usually not trigger side effects. It might be a good idea to check the
|
|
|
|
|
kEventParamTextInputSendFixLen parameter and verify if input is being confirmed (see CarbonEvents.h).
|
|
|
|
|
On the other hand, it can be useful for some applications to react to uncommitted text (for example,
|
|
|
|
|
to update a status display), as long as it does not disrupt the inline input session. Ideally, wx
|
|
|
|
|
should add new event types to support advanced text input. For now, I would keep things as they are.
|
|
|
|
|
|
|
|
|
|
However, the code that was being used caused additional problems:
|
|
|
|
|
However, the code that was being used caused additional problems:
|
|
|
|
|
UInt32 message = (0 << 8) + ((char)uniChars[pos] );
|
|
|
|
|
Since it simply truncated the unichar to the last byte, it ended up causing weird bugs with inline
|
|
|
|
|
input, such as switching to another field when one attempted to insert the character U+4E09 (the kanji
|
|
|
|
|
for "three"), because it was truncated to 09 (kTabCharCode), which was later "converted" to WXK_TAB
|
|
|
|
|
(still 09) in wxMacTranslateKey; or triggering the default button when one attempted to insert U+840D
|
|
|
|
|
(the kanji for "name"), which got truncated to 0D and interpreted as a carriage return keypress.
|
|
|
|
|
Note that even single-byte characters could have been misinterpreted, since MacRoman charcodes only
|
|
|
|
|
overlap with Unicode within the (7-bit) ASCII range.
|
|
|
|
|
But simply passing a NUL charcode would disable text updated events, because wxTextCtrl::OnChar checks
|
|
|
|
|
for codes within a specific range. Therefore I went for the solution seen above, which keeps ASCII
|
|
|
|
|
characters as they are and replaces the rest with '?', ensuring that update events are triggered.
|
|
|
|
|
It would be better to change wxTextCtrl::OnChar to look at the actual unicode character instead, but
|
|
|
|
|
I don't have time to look into that right now.
|
|
|
|
|
-- CL
|
|
|
|
|
Since it simply truncated the unichar to the last byte, it ended up causing weird bugs with inline
|
|
|
|
|
input, such as switching to another field when one attempted to insert the character U+4E09 (the kanji
|
|
|
|
|
for "three"), because it was truncated to 09 (kTabCharCode), which was later "converted" to WXK_TAB
|
|
|
|
|
(still 09) in wxMacTranslateKey; or triggering the default button when one attempted to insert U+840D
|
|
|
|
|
(the kanji for "name"), which got truncated to 0D and interpreted as a carriage return keypress.
|
|
|
|
|
Note that even single-byte characters could have been misinterpreted, since MacRoman charcodes only
|
|
|
|
|
overlap with Unicode within the (7-bit) ASCII range.
|
|
|
|
|
But simply passing a NUL charcode would disable text updated events, because wxTextCtrl::OnChar checks
|
|
|
|
|
for codes within a specific range. Therefore I went for the solution seen above, which keeps ASCII
|
|
|
|
|
characters as they are and replaces the rest with '?', ensuring that update events are triggered.
|
|
|
|
|
It would be better to change wxTextCtrl::OnChar to look at the actual unicode character instead, but
|
|
|
|
|
I don't have time to look into that right now.
|
|
|
|
|
-- CL
|
|
|
|
|
*/
|
|
|
|
|
if ( wxTheApp->MacSendCharEvent((wxWindow*)
|
|
|
|
|
focus , message , 0 , when , 0 , 0 , uniChars[pos] ) )
|
|
|
|
@@ -2815,7 +2815,7 @@ void wxWindowMac::OnInternalIdle()
|
|
|
|
|
{
|
|
|
|
|
// This calls the UI-update mechanism (querying windows for
|
|
|
|
|
// menu/toolbar/control state information)
|
|
|
|
|
if (wxUpdateUIEvent::CanUpdate(this))
|
|
|
|
|
if (wxUpdateUIEvent::CanUpdate(this) && IsShown())
|
|
|
|
|
UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|