Skip to content

Commit

Permalink
Don't open item on checkbox click
Browse files Browse the repository at this point in the history
When the checkboxes option is enabled, a checkbox will be shown next to
each item. Clicking the checkbox for an item will allow the item to be
selected/deselected. When the single-click to open an item option is
enabled, items will be opened with a single click, rather than the
standard double click.

Previously, when both of those options were enabled at once, clicking on
a checkbox would result in the item being opened. Now, the click will be
ignored if it occurs over an item's state icon. When checkboxes are
enabled, the state icon will be used to represent the checkbox. This has
the effect of ignoring the click if it occurs over the checkbox.

This fixes #499.
  • Loading branch information
derceg committed Dec 25, 2024
1 parent 4bf488b commit 3ffc66b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Documentation/User/History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ Bug fixes:
remain hidden until filtering was disabled.
- A saved dialog position will now only be used if the saved
position is visible on screen.
- When the single-click to open option and checkbox option are
both enabled, clicking on a checkbox would previously result in
the associated item being opened. Now, clicking on a checkbox
will consistently result in the selection state being toggled.
See #499.
- When renaming an item, the item is updated immediately if the
rename succeeds. Previously, the item details would be updated
a short time later. That meant that renaming an item, then
Expand Down
1 change: 1 addition & 0 deletions Explorer++/Explorer++/Explorer++.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ class Explorerplusplus :
void OnToolbarViews();

/* ListView private message handlers. */
void OnListViewClick(const NMITEMACTIVATE *eventInfo);
void OnListViewDoubleClick(const NMITEMACTIVATE *eventInfo);
LRESULT OnListViewKeyDown(LPARAM lParam);
void OnShowListViewContextMenu(const POINT &ptScreen);
Expand Down
20 changes: 20 additions & 0 deletions Explorer++/Explorer++/ListViewHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,26 @@ void Explorerplusplus::OnListViewItemRClick(POINT *pCursorPos)
}
}

void Explorerplusplus::OnListViewClick(const NMITEMACTIVATE *eventInfo)
{
if (!m_config->globalFolderSettings.oneClickActivate.get())
{
return;
}

LVHITTESTINFO htInfo = {};
htInfo.pt = eventInfo->ptAction;
ListView_HitTest(m_hActiveListView, &htInfo);

if (WI_IsFlagSet(htInfo.flags, LVHT_ONITEMSTATEICON) && m_config->checkBoxSelection.get())
{
// In this case, the click was on the checkbox, so it should be ignored.
return;
}

OnListViewDoubleClick(eventInfo);
}

void Explorerplusplus::OnListViewDoubleClick(const NMITEMACTIVATE *eventInfo)
{
// Note that while it's stated in the documentation for both NM_CLICK and NM_DBLCLK that "The
Expand Down
5 changes: 2 additions & 3 deletions Explorer++/Explorer++/MainWndSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1427,10 +1427,9 @@ LRESULT CALLBACK Explorerplusplus::NotifyHandler(HWND hwnd, UINT msg, WPARAM wPa
switch (nmhdr->code)
{
case NM_CLICK:
if (m_config->globalFolderSettings.oneClickActivate.get()
&& nmhdr->hwndFrom == m_hActiveListView)
if (nmhdr->hwndFrom == m_hActiveListView)
{
OnListViewDoubleClick(reinterpret_cast<NMITEMACTIVATE *>(lParam));
OnListViewClick(reinterpret_cast<NMITEMACTIVATE *>(lParam));
}
break;

Expand Down

0 comments on commit 3ffc66b

Please sign in to comment.