📄 text.tex
字号:
event.\membersection{wxTextCtrl::Copy}\label{wxtextctrlcopy}\func{virtual void}{Copy}{\void}Copies the selected text to the clipboard under Motif and MS Windows.\membersection{wxTextCtrl::Create}\label{wxtextctrlcreate}\func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id},\rtfsp\param{const wxString\& }{value = ``"}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = wxTextCtrlNameStr}}Creates the text control for two-step construction. Derived classesshould call or replace this function. See \helpref{wxTextCtrl::wxTextCtrl}{wxtextctrlctor}\rtfspfor further details.\membersection{wxTextCtrl::Cut}\label{wxtextctrlcut}\func{virtual void}{Cut}{\void}Copies the selected text to the clipboard and removes the selection.\membersection{wxTextCtrl::DiscardEdits}\label{wxtextctrldiscardedits}\func{void}{DiscardEdits}{\void}Resets the internal `modified' flag as if the current edits had been saved.\membersection{wxTextCtrl::EmulateKeyPress}\label{wxtextctrlemulatekeypress}\func{bool}{EmulateKeyPress}{\param{const wxKeyEvent\& }{event}}This functions inserts into the control the character which would have beeninserted if the given key event had occurred in the text control. The{\it event} object should be the same as the one passed to {\tt EVT\_KEY\_DOWN}handler previously by wxWidgets.Please note that this function doesn't currently work correctly for all keysunder any platform but MSW.\wxheading{Return value}{\tt true} if the event resulted in a change to the control, {\tt false}otherwise.\membersection{wxTextCtrl::GetDefaultStyle}\label{wxtextctrlgetdefaultstyle}\constfunc{const wxTextAttr\& }{GetDefaultStyle}{\void}Returns the style currently used for the new text.\wxheading{See also}\helpref{SetDefaultStyle}{wxtextctrlsetdefaultstyle}\membersection{wxTextCtrl::GetInsertionPoint}\label{wxtextctrlgetinsertionpoint}\constfunc{virtual long}{GetInsertionPoint}{\void}Returns the insertion point. This is defined as the zero based index of thecharacter position to the right of the insertion point. For example, ifthe insertion point is at the end of the text control, it is equal toboth \helpref{GetValue()}{wxtextctrlgetvalue}.Length() and\helpref{GetLastPosition()}{wxtextctrlgetlastposition}.The following code snippet safely returns the character at the insertionpoint or the zero character if the point is at the end of the control.{\small%\begin{verbatim} char GetCurrentChar(wxTextCtrl *tc) { if (tc->GetInsertionPoint() == tc->GetLastPosition()) return '\0'; return tc->GetValue[tc->GetInsertionPoint()]; }\end{verbatim}}%\membersection{wxTextCtrl::GetLastPosition}\label{wxtextctrlgetlastposition}\constfunc{virtual wxTextPos}{GetLastPosition}{\void}Returns the zero based index of the last position in the text control,which is equal to the number of characters in the control.\membersection{wxTextCtrl::GetLineLength}\label{wxtextctrlgetlinelength}\constfunc{int}{GetLineLength}{\param{long}{ lineNo}}Gets the length of the specified line, not including any trailing newlinecharacter(s).\wxheading{Parameters}\docparam{lineNo}{Line number (starting from zero).}\wxheading{Return value}The length of the line, or -1 if {\it lineNo} was invalid.\membersection{wxTextCtrl::GetLineText}\label{wxtextctrlgetlinetext}\constfunc{wxString}{GetLineText}{\param{long}{ lineNo}}Returns the contents of a given line in the text control, not includingany trailing newline character(s).\wxheading{Parameters}\docparam{lineNo}{The line number, starting from zero.}\wxheading{Return value}The contents of the line.\membersection{wxTextCtrl::GetNumberOfLines}\label{wxtextctrlgetnumberoflines}\constfunc{int}{GetNumberOfLines}{\void}Returns the number of lines in the text control buffer.\wxheading{Remarks}Note that even empty text controls have one line (where the insertion pointis), so GetNumberOfLines() never returns $0$.For wxGTK using GTK+ 1.2.x and earlier, the number of lines in a multi-linetext control is calculated by actually counting newline characters in thebuffer, i.e. this function returns the number of logical lines and doesn'tdepend on whether any of them are wrapped. For all the other platforms, thenumber of physical lines in the control is returned.Also note that you may wish to avoid using functions that work with linenumbers if you are working with controls that contain large amounts of text asthis function has $O(N)$ complexity for $N$ being the number of lines.\membersection{wxTextCtrl::GetRange}\label{wxtextctrlgetrange}\constfunc{virtual wxString}{GetRange}{\param{long}{ from}, \param{long}{ to}}Returns the string containing the text starting in the positions {\it from} andup to {\it to} in the control. The positions must have been returned by anotherwxTextCtrl method.Please note that the positions in a multiline wxTextCtrl do {\bf not}correspond to the indices in the string returned by\helpref{GetValue}{wxtextctrlgetvalue} because of the different new linerepresentations ({\tt CR} or {\tt CR LF}) and so this method should be used toobtain the correct results instead of extracting parts of the entire value. Itmay also be more efficient, especially if the control contains a lot of data.\membersection{wxTextCtrl::GetSelection}\label{wxtextctrlgetselection}\constfunc{virtual void}{GetSelection}{\param{long*}{ from}, \param{long*}{ to}}Gets the current selection span. If the returned values are equal, there wasno selection.Please note that the indices returned may be used with the other wxTextctrlmethods but don't necessarily represent the correct indices into the stringreturned by \helpref{GetValue()}{wxtextctrlgetvalue} for multiline controlsunder Windows (at least,) you should use\helpref{GetStringSelection()}{wxtextctrlgetstringselection} to get the selectedtext.\wxheading{Parameters}\docparam{from}{The returned first position.}\docparam{to}{The returned last position.}\pythonnote{The wxPython version of this method returns a tupleconsisting of the from and to values.}\perlnote{In wxPerl this method takes no parameter and returns a2-element list {\tt ( from, to )}.}\membersection{wxTextCtrl::GetStringSelection}\label{wxtextctrlgetstringselection}\func{virtual wxString}{GetStringSelection}{\void}Gets the text currently selected in the control. If there is no selection, thereturned string is empty.\membersection{wxTextCtrl::GetStyle}\label{wxtextctrlgetstyle}\func{bool}{GetStyle}{\param{long }{position}, \param{wxTextAttr\& }{style}}Returns the style at this position in the text control. Not all platformssupport this function.\wxheading{Return value}{\tt true} on success, {\tt false} if an error occurred - it may also mean thatthe styles are not supported under this platform.\wxheading{See also}\helpref{wxTextCtrl::SetStyle}{wxtextctrlsetstyle}, \helpref{wxTextAttr}{wxtextattr}\membersection{wxTextCtrl::GetValue}\label{wxtextctrlgetvalue}\constfunc{wxString}{GetValue}{\void}Gets the contents of the control. Notice that for a multiline text control,the lines will be separated by (Unix-style) $\backslash$n characters, evenunder Windows where they are separated by a $\backslash$r$\backslash$nsequence in the native control.\membersection{wxTextCtrl::HitTest}\label{wxtextctrlhittest}\constfunc{wxTextCtrlHitTestResult}{HitTest}{\param{const wxPoint\& }{pt}, \param{wxTextCoord }{*col}, \param{wxTextCoord }{*row}}This function finds the character at the specified position expressed inpixels. If the return code is not \texttt{wxTE\_HT\_UNKNOWN} the row and columnof the character closest to this position are returned in the \arg{col} and\arg{row} parameters (unless the pointers are {\tt NULL} which is allowed).Please note that this function is currently only implemented in wxUniv,wxMSW and wxGTK2 ports.\wxheading{See also}\helpref{PositionToXY}{wxtextctrlpositiontoxy}, \helpref{XYToPosition}{wxtextctrlxytoposition}\perlnote{In wxPerl this function takes only the position argument andreturns a 3-element list \texttt{(result, col, row)}}.\membersection{wxTextCtrl::IsEditable}\label{wxtextctrliseditable}\constfunc{bool}{IsEditable}{\void}Returns {\tt true} if the controls contents may be edited by user (note that italways can be changed by the program), i.e. if the control hasn't been put inread-only mode by a previous call to\helpref{SetEditable}{wxtextctrlseteditable}.\membersection{wxTextCtrl::IsEmpty}\label{wxtextctrlisempty}\constfunc{bool}{IsEmpty}{\void}Returns \true if the control is currently empty. This is the same as \texttt{GetValue().empty()} but can be much more efficient for the multilinecontrols containing big amounts of text.\newsince{2.7.1}\membersection{wxTextCtrl::IsModified}\label{wxtextctrlismodified}\constfunc{bool}{IsModified}{\void}Returns {\tt true} if the text has been modified by user. Note that calling\helpref{SetValue}{wxtextctrlsetvalue} doesn't make the control modified.\wxheading{See also}\helpref{MarkDirty}{wxtextctrlmarkdirty}\membersection{wxTextCtrl::IsMultiLine}\label{wxtextctrlismultiline}\constfunc{bool}{IsMultiLine}{\void}Returns {\tt true} if this is a multi line edit control and {\tt false}otherwise.\wxheading{See also}\helpref{IsSingleLine}{wxtextctrlissingleline}\membersection{wxTextCtrl::IsSingleLine}\label{wxtextctrlissingleline}\constfunc{bool}{IsSingleLine}{\void}Returns {\tt true} if this is a single line edit control and {\tt false}otherwise.\wxheading{See also}\helpref{IsMultiLine}{wxtextctrlissingleline}\membersection{wxTextCtrl::LoadFile}\label{wxtextctrlloadfile}\func{bool}{LoadFile}{\param{const wxString\& }{ filename}, \param{int }{fileType = wxTEXT\_TYPE\_ANY}}Loads and displays the named file, if it exists.\wxheading{Parameters}\docparam{filename}{The filename of the file to load.}\docparam{fileType}{The type of file to load. This is currently ignored in wxTextCtrl.}\wxheading{Return value}{\tt true} if successful, {\tt false} otherwise.% VZ: commenting this out as: (a) the docs are wrong (you can't replace% anything), (b) wxTextCtrl doesn't have any OnChar() anyhow%% \membersection{wxTextCtrl::OnChar}\label{wxtextctrlonchar}%%%% \func{void}{OnChar}{\param{wxKeyEvent\& }{event}}%%%% Default handler for character input.%%%% \wxheading{Remarks}%%%% It is possible to intercept character%% input by overriding this member. Call this function%% to let the default behaviour take place; not calling%% it results in the character being ignored. You can%% replace the {\it keyCode} member of {\it event} to%% translate keystrokes.%%%% Note that Windows and Motif have different ways%% of implementing the default behaviour. In Windows,%% calling wxTextCtrl::OnChar immediately%% processes the character. In Motif,%% calling this function simply sets a flag%% to let default processing happen. This might affect%% the way in which you write your OnChar function%% on different platforms.%%%% \wxheading{See also}%%%% \helpref{wxKeyEvent}{wxkeyevent}\membersection{wxTextCtrl::MarkDirty}\label{wxtextctrlmarkdirty}\func{void}{MarkDirty}{\void}Mark text as modified (dirty).\wxheading{See also}\helpref{IsModified}{wxtextctrlismodified}\membersection{wxTextCtrl::OnDropFiles}\label{wxtextctrlondropfiles}\func{void}{OnDropFiles}{\param{wxDropFilesEvent\& }{event}}This event handler function implements default drag and drop behaviour, which
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -