HaikuDepot: React to B_SELECT_ALL in custom text view
This commit is contained in:
parent
639756547d
commit
96ebc1d602
|
@ -52,6 +52,9 @@ TextDocumentView::MessageReceived(BMessage* message)
|
|||
case B_COPY:
|
||||
Copy(be_clipboard);
|
||||
break;
|
||||
case B_SELECT_ALL:
|
||||
SelectAll();
|
||||
break;
|
||||
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
|
@ -334,6 +337,18 @@ TextDocumentView::SetCaret(BPoint location, bool extendSelection)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
TextDocumentView::SelectAll()
|
||||
{
|
||||
if (fTextEditor.Get() == NULL)
|
||||
return;
|
||||
|
||||
fTextEditor->SelectAll();
|
||||
fShowCaret = false;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TextDocumentView::HasSelection() const
|
||||
{
|
||||
|
@ -344,7 +359,7 @@ TextDocumentView::HasSelection() const
|
|||
void
|
||||
TextDocumentView::GetSelection(int32& start, int32& end) const
|
||||
{
|
||||
if (fTextEditor.Get()) {
|
||||
if (fTextEditor.Get() != NULL) {
|
||||
start = fTextEditor->SelectionStart();
|
||||
end = fTextEditor->SelectionEnd();
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
|
||||
void SetCaret(BPoint where, bool extendSelection);
|
||||
|
||||
void SelectAll();
|
||||
bool HasSelection() const;
|
||||
void GetSelection(int32& start, int32& end) const;
|
||||
|
||||
|
|
|
@ -119,6 +119,16 @@ TextEditor::SetCaret(BPoint location, bool extendSelection)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
TextEditor::SelectAll()
|
||||
{
|
||||
if (fDocument.Get() == NULL)
|
||||
return;
|
||||
|
||||
SetSelection(TextSelection(0, fDocument->Length()));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TextEditor::SetSelection(TextSelection selection)
|
||||
{
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
{ return fEditingEnabled; }
|
||||
|
||||
void SetCaret(BPoint location, bool extendSelection);
|
||||
void SelectAll();
|
||||
void SetSelection(TextSelection selection);
|
||||
inline TextSelection Selection() const
|
||||
{ return fSelection; }
|
||||
|
|
Loading…
Reference in New Issue