diff options
author | George Hazan <george.hazan@gmail.com> | 2023-10-04 17:04:14 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-10-04 17:04:14 +0300 |
commit | d9c207c8bc8cb949572965cf81837180c55850e3 (patch) | |
tree | abe5d01cf73f0a63e67852f15c00c9d9c9e92c5d /plugins | |
parent | 375ee2dde56a86f64fa44b83ede37bcb11c47cb3 (diff) |
NewStory: fix for rclick
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/NewStory/src/history_array.cpp | 2 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.h | 2 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 13 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.h | 3 |
4 files changed, 15 insertions, 5 deletions
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 48656c1f56..7cfafa7b16 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -505,7 +505,7 @@ int HistoryArray::find(MEVENT hEvent) return -1; } -ItemData* HistoryArray::get(int id, bool bLoad) +ItemData* HistoryArray::get(int id, bool bLoad) const { int pageNo = id / HIST_BLOCK_SIZE; if (pageNo >= pages.getCount()) diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h index 00a8b9ae0d..cfefca9612 100644 --- a/plugins/NewStory/src/history_array.h +++ b/plugins/NewStory/src/history_array.h @@ -140,7 +140,7 @@ public: pages.insert(new ItemBlock()); } - ItemData* get(int id, bool bLoad = false); + ItemData* get(int id, bool bLoad = false) const; __forceinline int FindNext(int id, const Filter &filter) { return find(id, +1, filter); } __forceinline int FindPrev(int id, const Filter &filter) { return find(id, -1, filter); } diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index 7b49f59d70..d62a0cb892 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -432,7 +432,7 @@ void NewstoryListData::FixScrollPosition(bool bForce) } } -ItemData* NewstoryListData::GetItem(int idx) +ItemData* NewstoryListData::GetItem(int idx) const { if (totalCount == 0) return nullptr; @@ -491,6 +491,15 @@ int NewstoryListData::GetItemHeight(int index) return item->savedHeight = sz.cy + 5; } +bool NewstoryListData::HasSelection() const +{ + for (int i = 0; i < totalCount; i++) + if (auto *p = GetItem(i)) + return true; + + return false; +} + ItemData* NewstoryListData::LoadItem(int idx) { if (totalCount == 0) @@ -894,7 +903,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM if (data->caret != idx) data->EndEditItem(false); data->SetCaret(idx); - if (data->selStart == -1) + if (!data->HasSelection()) data->SetSelection(idx, idx); data->OnContextMenu(idx, pt); } diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h index e87af1a1bd..c2b722a90e 100644 --- a/plugins/NewStory/src/history_control.h +++ b/plugins/NewStory/src/history_control.h @@ -70,9 +70,10 @@ struct NewstoryListData : public MZeroedObject int FindNext(const wchar_t *pwszText); int FindPrev(const wchar_t *pwszText); void FixScrollPosition(bool bForce = false); - ItemData* GetItem(int idx); + ItemData* GetItem(int idx) const; int GetItemFromPixel(int yPos); int GetItemHeight(int index); + bool HasSelection() const; void LineUp(); void LineDown(); ItemData* LoadItem(int idx); |