Home || Visual Search || Applications || Architecture || Important Messages || OGL || Src

virtual void OglGui::TextField::KeyboardFunc ( int  c,
int  state 
) [inline, virtual]

Reimplemented from OglGui::Window.

Definition at line 122 of file TextField.h.

References DeleteSelection(), OglGui::Window::KeyboardFunc(), mCaretPosition, mListener, mListenerData, mMarkerPosition, OglGui::StaticText::mText, and OglGui::TextFieldListener::TextFieldChangedEvent().

00123     {
00124         // RvB: By not calling next line, we would prevent key commands from
00125         // view(3d)Sys. In old version OxKeyboardFunc was called.
00126         // Therefor also an OxWnd key event listener was triggered.
00127         // For now decided to pass onto OxWnd as then the oxWndKeyboardEvent
00128         // is triggered and user can therefor listen!!!
00129         // To solve OGLView commands: SetDisableOGLView(Keys)(Mouse)
00130         Window::KeyboardFunc(c, state);
00131         std::string oldText = mText;
00132         bool shift = (state & oglShift) != 0;
00133 
00134         if (c == oglLEFT)
00135         {
00136             if (mCaretPosition > 0)
00137                 mCaretPosition--;
00138             if (!shift)
00139                 mMarkerPosition = mCaretPosition;
00140         }
00141         if (c == oglRIGHT)
00142         {
00143             if (mCaretPosition < mText.size())
00144                 mCaretPosition++;
00145             if (!shift)
00146                 mMarkerPosition = mCaretPosition;
00147         }
00148         if (c == oglHOME)
00149         {
00150             mCaretPosition = 0;
00151             if (!shift)
00152                 mMarkerPosition = mCaretPosition;
00153         }
00154         if (c == oglEND)
00155         {
00156             mCaretPosition = mText.size();
00157             if (!shift)
00158                 mMarkerPosition = mCaretPosition;
00159         }
00160 
00161         if (c == 0x08) // backspace
00162         {
00163             if (mCaretPosition != mMarkerPosition)
00164             {
00165                 DeleteSelection();
00166             }
00167             else
00168                 if (mCaretPosition > 0)
00169                 {
00170                     mCaretPosition--;
00171                     mMarkerPosition = mCaretPosition;
00172                     mText = mText.erase(mCaretPosition, 1);
00173                 }
00174             //RvB: return;
00175         }
00176         if (c == oglDELETE) 
00177         {
00178             if (mCaretPosition != mMarkerPosition)
00179             {
00180                 DeleteSelection();
00181             }
00182             else
00183                 if (mCaretPosition < mText.size()-1)
00184                 {
00185                     mText = mText.erase(mCaretPosition, 1);
00186                 }
00187             //RvB: return;
00188         }
00189         unsigned char ch = (unsigned char) c;
00190         if (isalnum(ch) || ch == ' ' || ispunct(ch))
00191         {
00192             if (mCaretPosition != mMarkerPosition)
00193                 DeleteSelection();
00194             mText.insert(mCaretPosition, 1, ch);
00195             mCaretPosition++;
00196             mMarkerPosition = mCaretPosition;
00197         }
00198         if (oldText.compare(mText) && mListener)
00199             mListener->TextFieldChangedEvent(this, mListenerData);
00200 
00201     }

Here is the call graph for this function:


Generated on Thu Jan 13 09:27:07 2011 for ImpalaSrc by  doxygen 1.5.1