On Oct 23, 2012, at 2:24 AM, alex wrote:

>  am always getting nil returned by REALGetControlHandle()
> I think this is because only objects based on RealControl have the Handle 
> property.
>       
> For the moment I am resorting to a workaround of also placing an extra Canvas 
> object
> on my Window and passing the handle of that Canvas object to my control.
>       
> How can I make my control to inherit the properties of a RealControl object ?

Call [init] in the constructor callback of the REALcontrol:

                        ControlData(myControl, instance, myViewData, data);

        NSRect newFrame;
        Rect bounds;
        REALGetControlBounds(instance, &bounds);
        newFrame.size.width = bounds.right - bounds.left;
        newFrame.size.height = bounds.bottom - bounds.top;
        
        newFrame.origin.x = bounds.left;
        newFrame.origin.y = bounds.top;

        myView* ed = [[myView alloc] initWithFrame: newFrame];

        myViewData->theView = ed;

Make sure you implement the HandleGetter callback of the REALcontrol:

unsigned long HandleGetter(REALcontrolInstance instance) 
{
                        ControlData(myControl, instance, myViewData, data);
        return (unsigned long)myViewData->theView;
}

This way, you get what you want. The Redraw callback will not be called, 
because REALcontrol-cocoa will handle almost everything, including giving time 
to your view's draw implementation. No need to call REALcontrolHandle to add 
your view to the view hierarchy.

- Alfred Van Hoek
[email protected]
http://vanhoekplugins.com

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to