| 902 | } |
| 903 | |
| 904 | bool CUi::DoEditBox(CLineInput *pLineInput, const CUIRect *pRect, float FontSize, int Corners, const std::vector<STextColorSplit> &vColorSplits) |
| 905 | { |
| 906 | const bool Inside = MouseHovered(pRect); |
| 907 | const bool Active = m_pLastActiveItem == pLineInput; |
| 908 | const bool Changed = pLineInput->WasChanged(); |
| 909 | const bool CursorChanged = pLineInput->WasCursorChanged(); |
| 910 | |
| 911 | const float VSpacing = 2.0f; |
| 912 | CUIRect Textbox; |
| 913 | pRect->VMargin(VSpacing, &Textbox); |
| 914 | |
| 915 | bool JustGotActive = false; |
| 916 | if(CheckActiveItem(pLineInput)) |
| 917 | { |
| 918 | if(MouseButton(0)) |
| 919 | { |
| 920 | if(pLineInput->IsActive() && (Input()->HasComposition() || Input()->GetCandidateCount())) |
| 921 | { |
| 922 | // Clear IME composition/candidates on mouse press |
| 923 | Input()->StopTextInput(); |
| 924 | Input()->StartTextInput(); |
| 925 | } |
| 926 | } |
| 927 | else |
| 928 | { |
| 929 | SetActiveItem(nullptr); |
| 930 | } |
| 931 | } |
| 932 | else if(HotItem() == pLineInput) |
| 933 | { |
| 934 | if(MouseButton(0)) |
| 935 | { |
| 936 | if(!Active) |
| 937 | JustGotActive = true; |
| 938 | SetActiveItem(pLineInput); |
| 939 | } |
| 940 | } |
| 941 | |
| 942 | if(Inside && !MouseButton(0)) |
| 943 | SetHotItem(pLineInput); |
| 944 | |
| 945 | if(Enabled() && Active && !JustGotActive) |
| 946 | pLineInput->Activate(EInputPriority::UI); |
| 947 | else |
| 948 | pLineInput->Deactivate(); |
| 949 | |
| 950 | float ScrollOffset = pLineInput->GetScrollOffset(); |
| 951 | float ScrollOffsetChange = pLineInput->GetScrollOffsetChange(); |
| 952 | |
| 953 | // Update mouse selection information |
| 954 | CLineInput::SMouseSelection *pMouseSelection = pLineInput->GetMouseSelection(); |
| 955 | if(Inside) |
| 956 | { |
| 957 | if(!pMouseSelection->m_Selecting && MouseButtonClicked(0)) |
| 958 | { |
| 959 | pMouseSelection->m_Selecting = true; |
| 960 | pMouseSelection->m_PressMouse = MousePos(); |
| 961 | pMouseSelection->m_Offset.x = ScrollOffset; |
no test coverage detected