Skip to content

Commit

Permalink
when selecting annotation via listbox, don't set focus in edit box
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed Nov 17, 2023
1 parent f3e4d87 commit 55fbdd6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/EditAnnotations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void DeleteAnnotationAndUpdateUI(WindowTab* tab, Annotation* annot) {
}
#endif
}
SetSelectedAnnotation(tab, selectNext);
SetSelectedAnnotation(tab, selectNext, false);
}

static void DeleteSelectedAnnotation(EditAnnotationsWindow* ew) {
Expand Down Expand Up @@ -802,7 +802,7 @@ static void OpacityChanging(EditAnnotationsWindow* ew, TrackbarPosChangingEvent*
}

// TODO: maybe use ew->tab->selectedAnnotation instead of annot
static void UpdateUIForSelectedAnnotation(EditAnnotationsWindow* ew, Annotation* annot) {
static void UpdateUIForSelectedAnnotation(EditAnnotationsWindow* ew, Annotation* annot, bool setEditFocus) {
HidePerAnnotControls(ew);
if (annot) {
int itemNo = ew->annotations.Find(annot);
Expand Down Expand Up @@ -831,10 +831,10 @@ static void UpdateUIForSelectedAnnotation(EditAnnotationsWindow* ew, Annotation*
DoSaveEmbed(ew, annot);

// TODO: not sure it should be here as it might trigger recursive loop
SetSelectedAnnotation(ew->tab, annot);
//SetSelectedAnnotation(ew->tab, annot);
ew->listBox->SetCurrentSelection(itemNo);
ew->buttonDelete->SetIsVisible(true);
if (ew->editContents->IsVisible()) {
if (setEditFocus && ew->editContents->IsVisible()) {
ew->editContents->SetFocus();
ew->editContents->SetCursorPositionAtEnd();
}
Expand Down Expand Up @@ -891,7 +891,7 @@ static void ButtonEmbedAttachment(EditAnnotationsWindow* ew) {
MessageBoxNYI(ew->hwnd);
}

void SetSelectedAnnotation(WindowTab* tab, Annotation* annot) {
void SetSelectedAnnotation(WindowTab* tab, Annotation* annot, bool setEditFocus) {
// when we delete an annotation we automatically pick one to
// set as selected and it might end up as currently selected
// we still want to redraw to not show deleted annotation
Expand All @@ -908,7 +908,7 @@ void SetSelectedAnnotation(WindowTab* tab, Annotation* annot) {
auto ew = tab->editAnnotsWindow;
// go to page with a given annotations before triggering repaint
if (ew) {
UpdateUIForSelectedAnnotation(ew, annot);
UpdateUIForSelectedAnnotation(ew, annot, setEditFocus);
HwndMakeVisible(ew->hwnd);
}
MainWindowRerender(win);
Expand Down Expand Up @@ -938,7 +938,7 @@ void EditAnnotationsWindow::ListBoxSelectionChanged() {
return;
}
Annotation* annot = annotations.at(itemNo);
SetSelectedAnnotation(tab, annot);
SetSelectedAnnotation(tab, annot, false);
}

static UINT_PTR gMainWindowRerenderTimer = 0;
Expand Down Expand Up @@ -1440,7 +1440,7 @@ void ShowEditAnnotationsWindow(WindowTab* tab) {
Annotation* annot = ew->tab->selectedAnnotation;
ew->skipGoToPage = (annot != nullptr);
if (annot) {
UpdateUIForSelectedAnnotation(ew, annot);
UpdateUIForSelectedAnnotation(ew, annot, true);
}
// important to call this after hooking up onSize to ensure
// first layout is triggered
Expand Down
2 changes: 1 addition & 1 deletion src/EditAnnotations.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ struct EditAnnotationsWindow;
void ShowEditAnnotationsWindow(WindowTab*);
bool CloseAndDeleteEditAnnotationsWindow(WindowTab*);
void DeleteAnnotationAndUpdateUI(WindowTab*, Annotation*);
void SetSelectedAnnotation(WindowTab*, Annotation*);
void SetSelectedAnnotation(WindowTab*, Annotation*, bool setEditFocus = true);
void UpdateAnnotationsList(EditAnnotationsWindow*);
void NotifyAnnotationsChanged(EditAnnotationsWindow*);

0 comments on commit 55fbdd6

Please sign in to comment.