Skip to content

Commit

Permalink
fix of disabled Buttons when automated switch from Selection to All R…
Browse files Browse the repository at this point in the history
…adio
  • Loading branch information
daddel80 committed Aug 14, 2023
1 parent 3edde4e commit 4300410
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/MultiReplacePanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,16 @@ class MultiReplace : public DockingDlgInterface
// static Functions used in beNotified in MultiReplace.cpp
static bool isWindowOpen;
static void onSelectionChanged() {

if (!isWindowOpen) {
return;
}

static bool wasTextSelected = false; // This stores the previous state
const std::vector<int> selectionRadioDisabledButtons = {
IDC_FIND_BUTTON, IDC_FIND_NEXT_BUTTON, IDC_FIND_PREV_BUTTON, IDC_REPLACE_BUTTON
};

// Get the start and end of the selection
Sci_Position start = ::SendMessage(MultiReplace::getScintillaHandle(), SCI_GETSELECTIONSTART, 0, 0);
Sci_Position end = ::SendMessage(MultiReplace::getScintillaHandle(), SCI_GETSELECTIONEND, 0, 0);
Expand All @@ -194,8 +200,17 @@ class MultiReplace : public DockingDlgInterface
::SendMessage(::GetDlgItem(getDialogHandle(), IDC_ALL_TEXT_RADIO), BM_SETCHECK, BST_CHECKED, 0);
::SendMessage(::GetDlgItem(getDialogHandle(), IDC_SELECTION_RADIO), BM_SETCHECK, BST_UNCHECKED, 0);
}

// Check if there was a switch from selected to not selected
if (wasTextSelected && !isTextSelected) {
if (instance != nullptr) {
instance->setElementsState(selectionRadioDisabledButtons, true);
}
}
wasTextSelected = isTextSelected; // Update the previous state
}


static bool textModified;
static void onTextChanged() {
textModified = true;
Expand Down

0 comments on commit 4300410

Please sign in to comment.