Changeset 18

Show
Ignore:
Timestamp:
02/18/08 01:43:59 (7 months ago)
Author:
Chris Miller
Message:

Fixed mnemonic (control/menu) issues.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/win32/dfl/button.d

    r7 r18  
    231231        //return GetDlgCtrlID(m.hWnd) == IDOK; 
    232232        return isdef; 
     233    } 
     234     
     235     
     236    protected override bool processMnemonic(dchar charCode) 
     237    { 
     238        if(canSelect) 
     239        { 
     240            if(isMnemonic(charCode, text)) 
     241            { 
     242                select(); 
     243                //performClick(); 
     244                onClick(EventArgs.empty); 
     245                return true; 
     246            } 
     247        } 
     248        return false; 
    233249    } 
    234250     
  • trunk/win32/dfl/control.d

    r17 r18  
    37103710            return; 
    37113711         
     3712        // To-do: check if correct implementation. 
    37123713        Control ctrl; 
    3713          
    3714         if(directed
    3715         { 
    3716             SendMessageA(hwnd, WM_NEXTDLGCTL, !forward, MAKELPARAM(false, 0)); // TODO: fix..
    3717             /+ 
    3718             ctrl = Control.fromChildHandle(GetFocus()); 
    3719             if(ctrl) 
    3720             { 
    3721                ctrl = getNextControl(ctrl, forward, true); 
    3722                if(ctrl
    3723                    ctrl.select(); 
    3724             } 
    3725             +/ 
     3714        ctrl = findForm(); 
     3715        if(ctrl && ctrl !is this
     3716        { 
     3717            // Even if directed, ensure THIS one is selected first
     3718            if(!directed || hwnd != GetFocus()) 
     3719            { 
     3720               DefDlgProcA(ctrl.handle, WM_NEXTDLGCTL, cast(WPARAM)hwnd, MAKELPARAM(true, 0)); 
     3721            } 
     3722             
     3723            if(directed
     3724            { 
     3725               DefDlgProcA(ctrl.handle, WM_NEXTDLGCTL, !forward, MAKELPARAM(false, 0)); 
     3726            } 
    37263727        } 
    37273728        else 
    37283729        { 
    3729             ctrl = findForm(); 
    3730             if(ctrl && ctrl !is this) 
    3731             { 
    3732                 //SendMessageA(ctrl.handle, WM_NEXTDLGCTL, cast(WPARAM)hwnd, MAKELPARAM(true, 0)); 
    3733                 DefDlgProcA(ctrl.handle, WM_NEXTDLGCTL, cast(WPARAM)hwnd, MAKELPARAM(true, 0)); 
    3734             } 
    3735             else 
    3736             { 
    3737                 focus(); // This must be a form so just focus it ? 
    3738             } 
     3730            focus(); // This must be a form so just focus it ? 
    37393731        } 
    37403732    } 
     
    65306522     
    65316523     
    6532     /+ 
    6533     deprecated protected bool processMnemonic(dchar charCode) 
     6524    /// 
     6525    protected bool processMnemonic(dchar charCode) 
    65346526    { 
    65356527        return false; 
    65366528    } 
    6537     +/ 
     6529     
     6530     
     6531    package bool _processMnemonic(dchar charCode) 
     6532    { 
     6533        return processMnemonic(charCode); 
     6534    } 
    65386535     
    65396536     
  • trunk/win32/dfl/form.d

    r16 r18  
    27432743                                return false; 
    27442744                             
     2745                            case Keys.UP, Keys.DOWN: 
     2746                            case Keys.RIGHT, Keys.LEFT: 
     2747                                if(dfl.internal.utf.isDialogMessage(form.handle, &m._winMsg)) 
     2748                                    return true; // Prevent. 
     2749                                return false; // Continue. 
     2750                             
    27452751                            case Keys.TAB: 
    27462752                                { 
     
    27912797                } 
    27922798                 
     2799                /+ 
    27932800                switch(m.msg) 
    27942801                { 
     
    28152822                        return true; // Prevent. 
    28162823                } 
     2824                +/ 
     2825                switch(m.msg) 
     2826                { 
     2827                    case WM_SYSCHAR: 
     2828                        { 
     2829                            LRESULT dlgc; 
     2830                            dlgc = SendMessageA(m.hWnd, WM_GETDLGCODE, 0, 0); 
     2831                            if(dlgc & DLGC_WANTALLKEYS) 
     2832                                return false; // Continue. 
     2833                             
     2834                            size_t xiter; 
     2835                            bool _eachild(HWND hw, bool delegate(HWND hw) callback) 
     2836                            { 
     2837                                for(; hw; hw = GetWindow(hw, GW_HWNDNEXT)) 
     2838                                { 
     2839                                    if(!xiter) 
     2840                                        return false; 
     2841                                    xiter--; 
     2842                                     
     2843                                    LONG st = GetWindowLongA(hw, GWL_STYLE); 
     2844                                    if(!(st & WS_VISIBLE)) 
     2845                                        continue; 
     2846                                    if(st & WS_DISABLED) 
     2847                                        continue; 
     2848                                     
     2849                                    if(!callback(hw)) 
     2850                                        return false; 
     2851                                     
     2852                                    LONG exst = GetWindowLongA(hw, GWL_EXSTYLE); 
     2853                                    if(exst & WS_EX_CONTROLPARENT) 
     2854                                    { 
     2855                                        HWND hwc = GetWindow(hw, GW_CHILD); 
     2856                                        if(hwc) 
     2857                                        { 
     2858                                            if(!_eachild(hwc, callback)) 
     2859                                                return false; 
     2860                                        } 
     2861                                    } 
     2862                                } 
     2863                                return true; 
     2864                            } 
     2865                             
     2866                            void eachGoodChild(bool delegate(HWND hw) callback) 
     2867                            { 
     2868                                HWND hw = GetWindow(form.handle, GW_CHILD); 
     2869                                xiter = 2000; 
     2870                                _eachild(hw, callback); 
     2871                            } 
     2872                             
     2873                            bool pmnemonic(HWND hw) 
     2874                            { 
     2875                                Control cc = Control.fromHandle(hw); 
     2876                                //printf("mnemonic for "); 
     2877                                if(!cc) 
     2878                                { 
     2879                                    // To-do: check dlgcode for static/button and process. 
     2880                                    return false; 
     2881                                } 
     2882                                //printf("'%.*s' ", cc.name); 
     2883                                return cc._processMnemonic(cast(dchar)m.wParam); 
     2884                            } 
     2885                             
     2886                            bool foundmhw = false; 
     2887                            bool foundmn = false; 
     2888                            eachGoodChild( 
     2889                                (HWND hw) 
     2890                                { 
     2891                                    if(foundmhw) 
     2892                                    { 
     2893                                        if(pmnemonic(hw)) 
     2894                                        { 
     2895                                            foundmn = true; 
     2896                                            return false; // Break. 
     2897                                        } 
     2898                                    } 
     2899                                    else 
     2900                                    { 
     2901                                        if(hw == m.hWnd) 
     2902                                            foundmhw = true; 
     2903                                    } 
     2904                                    return true; // Continue. 
     2905                                }); 
     2906                            if(foundmn) 
     2907                                return true; // Prevent. 
     2908                             
     2909                            if(!foundmhw) 
     2910                            { 
     2911                                // Didn't find current control, so go from top-to-bottom. 
     2912                                eachGoodChild( 
     2913                                    (HWND hw) 
     2914                                    { 
     2915                                        if(pmnemonic(hw)) 
     2916                                        { 
     2917                                            foundmn = true; 
     2918                                            return false; // Break. 
     2919                                        } 
     2920                                        return true; // Continue. 
     2921                                    }); 
     2922                            } 
     2923                            else 
     2924                            { 
     2925                                // Didn't find mnemonic after current control, so go from top-to-this. 
     2926                                eachGoodChild( 
     2927                                    (HWND hw) 
     2928                                    { 
     2929                                        if(pmnemonic(hw)) 
     2930                                        { 
     2931                                            foundmn = true; 
     2932                                            return false; // Break. 
     2933                                        } 
     2934                                        if(hw == m.hWnd) 
     2935                                            return false; // Break. 
     2936                                        return true; // Continue. 
     2937                                    }); 
     2938                            } 
     2939                            if(foundmn) 
     2940                                return true; // Prevent. 
     2941                        } 
     2942                        break; 
     2943                     
     2944                    default: ; 
     2945                } 
    28172946            } 
    28182947             
  • trunk/win32/dfl/label.d

    r7 r18  
    361361     
    362362     
     363    protected override bool processMnemonic(dchar charCode) 
     364    { 
     365        if(visible && enabled) 
     366        { 
     367            if(isMnemonic(charCode, text)) 
     368            { 
     369                select(true, true); 
     370                return true; 
     371            } 
     372        } 
     373        return false; 
     374    } 
     375     
     376     
    363377    private: 
    364378    TextFormat _tfmt;