Selection changes via keyboard no longer copy DiskProbe's original behaviour, but can be done like in BTextView. Fixed a strange drawing bug that could happen on startup (R5): IsFocus() could return false, even if the view had focus.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7646 a95241bf-73f2-0310-859d-f6bbb57e9c96
Diff
src/apps/diskprobe/DataView.cpp | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
src/apps/diskprobe/DataView.h | 1 +
2 files changed, 84 insertions(+), 19 deletions(-)
@@ -55,12 +55,13 @@
fFocus(kHexFocus),
fBase(kHexBase),
fIsActive(true),
fMouseSelectionStart(-1),
fKeySelectionStart(-1),
fBitPosition(0),
fFitFontSize(false)
{
fPositionLength = 4;
fStart = fEnd = 0;
fMouseSelectionStart = -1;
if (fEditor.Lock()) {
fDataSize = fEditor.ViewSize();
@@ -93,6 +94,9 @@
DataView::AttachedToWindow()
{
fEditor.StartWatching(this);
MakeFocus(true);
}
@@ -915,7 +919,7 @@
void
DataView::MouseUp(BPoint where)
{
fMouseSelectionStart = -1;
fMouseSelectionStart = fKeySelectionStart = -1;
}
@@ -926,42 +930,102 @@
if (Looper()->CurrentMessage() == NULL
|| Looper()->CurrentMessage()->FindInt32("modifiers", &modifiers) != B_OK)
modifiers = ::modifiers();
switch (bytes[0]) {
case B_LEFT_ARROW:
case B_RIGHT_ARROW:
case B_UP_ARROW:
case B_DOWN_ARROW:
if (modifiers & B_SHIFT_KEY) {
if (fKeySelectionStart == -1)
fKeySelectionStart = fStart;
} else
fKeySelectionStart = -1;
break;
}
switch (bytes[0]) {
case B_LEFT_ARROW:
SetSelection(fStart - 1, modifiers & B_SHIFT_KEY ? fEnd : fStart - 1);
MakeVisible(fStart);
{
int32 position = fStart - 1;
if (modifiers & B_SHIFT_KEY) {
if (fKeySelectionStart == fEnd)
SetSelection(fStart - 1, fEnd);
else {
SetSelection(fStart, fEnd - 1);
position = fEnd;
}
} else
SetSelection(fStart - 1, fStart - 1);
MakeVisible(position);
break;
}
case B_RIGHT_ARROW:
SetSelection(modifiers & B_SHIFT_KEY ? fStart : fEnd + 1, fEnd + 1);
MakeVisible(fEnd);
{
int32 position = fEnd + 1;
if (modifiers & B_SHIFT_KEY) {
if (fKeySelectionStart == fStart)
SetSelection(fStart, fEnd + 1);
else
SetSelection(fStart + 1, fEnd);
} else
SetSelection(fEnd + 1, fEnd + 1);
MakeVisible(position);
break;
}
case B_UP_ARROW:
{
int32 start = fStart - int32(kBlockSize);
if (start < 0) {
if (modifiers & B_SHIFT_KEY)
int32 start, end;
if (modifiers & B_SHIFT_KEY) {
if (fKeySelectionStart == fStart) {
start = fEnd - int32(kBlockSize);
end = fStart;
} else {
start = fStart - int32(kBlockSize);
end = fEnd;
}
if (start < 0)
start = 0;
else
} else {
start = fStart - int32(kBlockSize);
if (start < 0)
start = fStart;
end = start;
}
SetSelection(start, modifiers & B_SHIFT_KEY ? fEnd : start);
MakeVisible(fStart);
SetSelection(start, end);
MakeVisible(start);
break;
}
case B_DOWN_ARROW:
{
int32 end = fEnd + int32(kBlockSize);
if (end >= int32(fSizeInView)) {
if (modifiers & B_SHIFT_KEY)
int32 start, end;
if (modifiers & B_SHIFT_KEY) {
if (fKeySelectionStart == fEnd) {
start = fEnd;
end = fStart + int32(kBlockSize);
} else {
start = fStart;
end = fEnd + int32(kBlockSize);
}
if (end >= int32(fSizeInView))
end = int32(fSizeInView) - 1;
else
end = fEnd;
} else {
end = fEnd + int32(kBlockSize);
if (end >= int32(fSizeInView))
start = fEnd;
start = end;
}
SetSelection(modifiers & B_SHIFT_KEY ? fStart : end, end);
MakeVisible(fEnd);
SetSelection(start, end);
MakeVisible(end);
break;
}
@@ -94,6 +94,7 @@
bool fIsActive;
int32 fStart, fEnd;
int32 fMouseSelectionStart;
int32 fKeySelectionStart;
int32 fBitPosition;
bool fFitFontSize;
};