Hi all.
I'm working on a VST plugin, which have to support both cocoa and carbon.
The cocoa version is ready, but i still have some troubles with carbon.
I really need help on this...
My main problem is to catch the kEventTextInputUnicodeForKeyEvent from the kEventClassTextInput class.
The host provide me a WindowRef. Then i create an HIView, i Register envent handlers, then add the HIView to the window.
I'm like this :
Then the events handlers:
then i add the control to the window :
I received the raw keys events, and others, but never kEventTextInputUnicodeForKeyEvent.
I can't figure what i'm doing wrong with this event.
Any help will be appreciated.
Thanks.
I'm working on a VST plugin, which have to support both cocoa and carbon.
The cocoa version is ready, but i still have some troubles with carbon.
I really need help on this...
My main problem is to catch the kEventTextInputUnicodeForKeyEvent from the kEventClassTextInput class.
The host provide me a WindowRef. Then i create an HIView, i Register envent handlers, then add the HIView to the window.
I'm like this :
Code:
// ============================================================================
// Control Creation
// ============================================================================
UInt32 features = kControlSupportsDragAndDrop
| kControlSupportsFocus
| kControlHandlesTracking
| kControlSupportsEmbedding
| kHIViewIsOpaque
| kHIViewFeatureDoesNotUseSpecialParts
| kHIViewFeatureGetsFocusOnClick;
Rect r = {(short)rcSize.top, (short)rcSize.left, (short)rcSize.bottom, (short)rcSize.right};
OSStatus status = CreateUserPaneControl (0, &r, features, &m_ControlRef);
if (status != noErr)
{
ASSERT(0);
}
Then the events handlers:
Code:
//============================================================================
// Control Event Handler
//============================================================================
const EventTypeSpec controlEventTypes[] = {
{ kEventClassControl, kEventControlDraw},
{ kEventClassControl, kEventControlHitTest},
{ kEventClassControl, kEventControlClick},
{ kEventClassMouse, kEventMouseWheelMoved},
{ kEventClassControl, kEventControlDragEnter},
{ kEventClassControl, kEventControlDragWithin},
{ kEventClassControl, kEventControlDragLeave},
{ kEventClassControl, kEventControlDragReceive},
{ kEventClassControl, kEventControlInitialize},
{ kEventClassControl, kEventControlGetClickActivation},
{ kEventClassControl, kEventControlGetOptimalBounds},
{ kEventClassScrollable,kEventScrollableGetInfo},
{ kEventClassScrollable,kEventScrollableScrollTo},
{ kEventClassControl, kEventControlSetFocusPart},
{ kEventClassControl, kEventControlGetFocusPart},
{ kEventClassControl, kEventControlTrackingAreaExited}
};
InstallControlEventHandler(m_ControlRef, carbonEventHandler, GetEventTypeCount(controlEventTypes), controlEventTypes, this, NULL);
//============================================================================
// Input Event Handler
//============================================================================
const EventTypeSpec keyInputEvents[] = {
{ kEventClassTextInput, kEventTextInputUnicodeForKeyEvent },
{ kEventClassWindow, kEventWindowFocusAcquired },
{ kEventClassWindow, kEventWindowFocusRelinquish },
{ kEventClassWindow, kEventTextInputUpdateActiveInputArea},
{ kEventClassKeyboard, kEventRawKeyDown},
{ kEventClassKeyboard, kEventRawKeyUp},
{ kEventClassKeyboard, kEventRawKeyRepeat}
};
InstallWindowEventHandler (HostWindowRef, carbonEventHandler, GetEventTypeCount(keyInputEvents), keyInputEvents, this, &m_KeyboardEventHandler);
//============================================================================
// Window Mouse Event Handler
//============================================================================
const EventTypeSpec mouseEvents[] = {
{ kEventClassMouse, kEventMouseDown },
{ kEventClassMouse, kEventMouseUp },
{ kEventClassMouse, kEventMouseMoved },
{ kEventClassMouse, kEventMouseDragged }
};
InstallWindowEventHandler(HostWindowRef, carbonMouseEventHandler, GetEventTypeCount(mouseEvents), mouseEvents, this, &m_MouseEventHandler);
then i add the control to the window :
Code:
//============================================================================
// Add control to window
//============================================================================
if (isWindowComposited(HostWindowRef))
{
HIViewRef contentView;
HIViewRef rootView = HIViewGetRoot(HostWindowRef);
if (HIViewFindByID(rootView, kHIViewWindowContentID, &contentView) != noErr)
{
contentView = rootView;
}
HIViewAddSubview (contentView, m_ControlRef);
}
else
{
ControlRef rootControl;
GetRootControl(HostWindowRef, &rootControl);
if (rootControl == NULL)
{
CreateRootControl(HostWindowRef, &rootControl);
}
EmbedControl(m_ControlRef, rootControl);
}
//============================================================================
// Add Tracking area
//============================================================================
HIViewTrackingAreaRef trackingAreaRef; // will automatically removed if view is destroyed
HIViewNewTrackingArea (m_ControlRef, 0, 0, &trackingAreaRef);
I received the raw keys events, and others, but never kEventTextInputUnicodeForKeyEvent.
I can't figure what i'm doing wrong with this event.
Any help will be appreciated.
Thanks.