It does help with blocking the "second" paste but then my
keystrokes are filtered out
by the same event. To block the second paste I'm returning noErr
and kEventParamReplacementText
paramater is not added to the event. All the other result scenarios
allow keystrokes but also allow the double
paste.
Is there something else I can try?
thanks!
Sam
On Wed, Apr 30, 2008 at 11:56 AM, Steve Christensen
<email@hidden> wrote:
On Apr 30, 2008, at 5:55 AM, Sam Mauney wrote:
I am currently calling a function where kHICommandPaste is
tripped that uses Pasteboard
functions so I can filter the pasted contents into an edit control.
I am having trouble overrriding or suppressing the normal paste.
So if I paste in the digit "2"
the result in the edit control will be "22".
What is the best way to override the normal paste so I can
prevent this from happening?
for 10.4 and later. If you install these on the edit control that
you want to filter, you can control which characters are accepted
by the control. It's a better solution than overriding paste in
general.
steve
------------------------------------
OSStatus CFilteredEditTextView::EventHandler(CCarbonEvent& theEvent)
{
OSStatus result = eventNotHandledErr;
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4
// handle filtering of text destined for the edit fields (10.0 -
10.3.9 method)
if ((theEvent.GetClass() == kEventClassTextInput) &&
(theEvent.GetKind() == kEventTextInputUnicodeForKeyEvent))
{
UInt32 dataSize = theEvent.GetParameterDataSize
(kEventParamTextInputSendText, typeUnicodeText);
if (dataSize > 0)
{
UniChar* data = reinterpret_cast<UniChar*>(malloc
(dataSize));
if (data != NULL)
{
theEvent.GetParameter(kEventParamTextInputSendText,
typeUnicodeText, dataSize, data);
// result = noErr; // don't specifically set noErr so
this will propogate automatically
}
}
}
else
#endif
// handle filtering of text destined for the edit fields (10.4+
method)
if ((theEvent.GetClass() == kEventClassTextField) &&
(theEvent.GetKind() == kEventTextShouldChangeInRange))
{
CFStringRef candidateTextRef;
if (replacementText != NULL)
{
theEvent.SetParameter
(kEventParamReplacementText, replacementText);
result = noErr;
}
}
free(unicode);
}
}
}
}
return result;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden