예제 #1
0
파일: Manager.cs 프로젝트: rinavin/RCJS
        /// <summary>
        ///   select all the text in the control, but do it immediately using guiInteractive (not the queue).
        /// </summary>
        /// <param name = "ctrl"> </param>
        public static void SetSelect(MgControlBase ctrl)
        {
            if (ctrl.isTextOrTreeEdit())
            {
                // if the control is modifiable, select the whole text in the control,
                // otherwise, unselect all.
                if (ctrl.isModifiable())
                {
                    PIC pic = ctrl.getPIC();
                    if ((UtilStrByteMode.isLocaleDefLangJPN() && !pic.isAttrBlob() && pic.getMaskChars() > 0 && !ctrl.isMultiline()) ||
                        (pic.isAttrDateOrTime() && ctrl.isAllBlanks(ctrl.Value)))
                    {
                        String strText  = ctrl.Value;
                        int    startPos = 0;
                        int    endPos   = strText.Length;

                        while (startPos < endPos)
                        {
                            if (strText[startPos] == ' ')
                            {
                                break;
                            }
                            else
                            {
                                if (!charIsMask(pic, strText, startPos))
                                {
                                    break;
                                }
                            }
                            startPos++;
                        }

                        while (startPos < endPos)
                        {
                            if (strText[endPos - 1] != ' ')
                            {
                                if (!charIsMask(pic, strText, endPos - 1))
                                {
                                    break;
                                }
                            }
                            endPos--;
                        }

                        SetSelection(ctrl, 0, 0, 0); // Cancel the selection to prevent the caret moving to the end of the field.
                        if (endPos != 0)
                        {
                            SetSelection(ctrl, startPos, endPos, 0); // Select the input text exclude the mask characters.
                        }
                    }
                    else
                    {
                        SetSelection(ctrl, 0, -1, -1);
                    }
                }
                else
                {
                    SetSelection(ctrl, 0, 0, 0);
                }
            }
        }