Regis St-Gelais wrote:
"Eric Potter" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED]

In my application, I create a new form with FrmNewForm, setting the modal flage to true. I display it with FrmDoDialog. But when I run it on the T5, the focus ring is not drawn. I though all Modal forms had the focus ring on by default. Is this a bug/loop-hole in the OS?

As a work around, I tried to turn the focus ring on automatically by calling

FrmSetNavState(FrmGetActiveForm(), kFrmNavStateFlagsObjectFocusMode);

on winEnterEvent and that didn't work. I also called it on the first nilEvent after winEnterEvent and that didn't work either.

Is there a way to turn on the focus ring on dynamically created forms?

Eric



If you want to set the focus to a specific control you need to use:
FrmGlueNavObjectTakeFocus(...)

That glue function works both for the old navigation system and the new one.

I can call FrmGlueNavObjectTakeFocus and it draws the focus ring, but I still can't move it around.

I've tried calling

FrmSetNavState(frmP, kFrmNavStateFlagsObjectFocusMode);

before I call FrmDoDialog, when I recieve the winEnterEvent, and when I recieve the first ctlEnterEvent. Whenever I call it, the T5 simulator throws these two fatal alerts.

HsNav.c, Line:6660, Memory allocation failed
HsNav.c, Line:5873, Error resetting vertical order

The call to FrmSetNavState returns an error code of 0x3A04, uilibErrObjectNotFound.

Is there some undocumented OS limitation that prevents dynamically created forms from going into Object Focus mode?

If it helps anyone, here is the source.

///////////////////////////////////////////////////////////////////////////////
//
// This function displays a simple dialog to the user
//
///////////////////////////////////////////////////////////////////////////////
static void DisplayDynamicForm()
{


    FormType *      pForm;
    Err err = errNone;

// Begin

        CreateDynamicForm();

        //Initialize the form
        pForm = FrmGetFormPtr(g_AlertID);
        
        if (NULL == pForm)
        {
            pForm = FrmInitForm(g_AlertID);
        }

        //Set the event hanlder
        FrmSetEventHandler(pForm, (FormEventHandlerType*)&AlerterHandleEvents);
        
        err = FrmSetNavState(pForm, kFrmNavStateFlagsObjectFocusMode);  
        
        //Display the form
        FrmDoDialog(pForm);

        //Delete the form
        FrmDeleteForm(pForm);

        
}

///////////////////////////////////////////////////////////////////////////////
//
// This function creates the form to be displayed
//
///////////////////////////////////////////////////////////////////////////////


static void CreateDynamicForm()
{
        

        
        
        //UInt16      buttonTaped;
        UInt8       controlID = 1;
        
        //form varables
    Coord           formUpperLeftX = 2; //left edge plus the border
    Coord           formUpperLeftY = 80; //left edge plus the border
    Coord           formWidth = 156; //right edge plus the border
    Coord           formHeight = 78; //right edge plus the border
    UInt16          defaultButtonID = g_FirstButtonID;
    UInt16          helpRscID = 0;
    UInt16          menuRscID = 0;
    Boolean         modal = true; //alerts are always modal
    FormType *      customForm;

    Coord           buttonWidth = 60;
    Coord           buttonHeight = 12;
    Coord           button1UpperLeftX = 5;
    Coord           button2UpperLeftX = 85;
    Coord           buttonUpperLeftY = 61;
    FontID          buttonFont = stdFont;
    ControlType*    buttonPointer;
    UInt16              button1ID = 60005;
    UInt16              button2ID = 60006;
    UInt8           buttonGroup = 0;
    Boolean         leftAnchor = true;

    //field variables
    va_list args = 0;



// Begin
customForm = FrmNewForm(g_AlertID, "My Title", formUpperLeftX, formUpperLeftY, formWidth, formHeight, modal, defaultButtonID, helpRscID, menuRscID);


buttonPointer = CtlNewControl((void**)&customForm, button1ID, buttonCtl, "Cancel",
        button1UpperLeftX, buttonUpperLeftY, buttonWidth, buttonHeight,
        buttonFont, buttonGroup, leftAnchor);


buttonPointer = CtlNewControl((void**)&customForm, button2ID, buttonCtl, "Continue",
        button2UpperLeftX, buttonUpperLeftY, buttonWidth, buttonHeight,
        buttonFont, buttonGroup, leftAnchor);
}

///////////////////////////////////////////////////////////////////////////////
//
// This function handles the events for the alert form
//
///////////////////////////////////////////////////////////////////////////////

static Boolean AlerterHandleEvents(EventType& event)
{
        Boolean handled = false;
        FrmNavStateFlagsType stateFlags;
        FormPtr frmP = FrmGetActiveForm();
        Err err = errNone;
        
        if(event.eType == ctlSelectEvent)
        {
        
                if (event.data.ctlSelect.controlID == g_FirstButtonID)
                {
                        err = FrmGetNavState(frmP, &stateFlags);
                
                        switch(stateFlags)
                        {
                        case kFrmNavStateFlagsObjectFocusMode:          
                                err = FrmSetNavState(frmP, 0);
                                break;
                                
                        default:
                                err = FrmSetNavState(frmP, 
kFrmNavStateFlagsObjectFocusMode);
                                FrmGlueNavObjectTakeFocus(frmP, 
g_FirstButtonID);               
                                break;  
                                        
                        }// end swtich stateFlags
                        
                        handled = true;
                        
                }// end handle g_FirstButtonID
                

        }

        
        
        return handled;
}


--
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to