开发者

SFAuthorizationPluginView identifying "BACK" button

开发者 https://www.devze.com 2022-12-13 23:43 出处:网络
Does anyone who has experience with SFAuthorizationPluginView know how to identify between the user pressing \"Cancel\" and \"Back\".My problem is that SFButtonTypeCancelis identical to SFButtonTypeBa

Does anyone who has experience with SFAuthorizationPluginView know how to identify between the user pressing "Cancel" and "Back". My problem is that SFButtonTypeCancel is identical to SFButtonTypeBack, hence a switch statement will fail at compile time, and an if statement will not recognize the difference.

T开发者_StackOverflow社区his is not a problem when displaying the login screen as "name and password", but when displaying as "List of Users", handling the "Back" as "Cancel" makes the login window restart instead of shifting nicely to the list.

Regards Alan


To answer my own question, the login window has a CANCEL button when Fast-User Switching, and a BACK button when in the login screen, therefore I managed to identify between the two buttons, by the following code:

    CFStringRef str_console_uname;
    uid_t       uid;
    gid_t       gid;

    // get console username
    str_console_uname = SCDynamicStoreCopyConsoleUser(NULL,
                                                      &uid,
                                                      &gid);
    if (!str_console_uname ||
        [(NSString *)str_console_uname compare:@"loginwindow"] == 0)
    {
        /* BACK BUTTON */
    }
    else
    {
        /* CANCEL BUTTON */
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消