Skip to content

Commit

Permalink
some test code, incomplete, for support of suppressing dropdown when …
Browse files Browse the repository at this point in the history
…returning from KB Editor without making changes in the KB Editor
  • Loading branch information
adaptitbruce committed Jul 13, 2024
1 parent 4e4c592 commit 75ddd7a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
2 changes: 2 additions & 0 deletions source/Adapt_It.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24160,6 +24160,8 @@ bool CAdapt_ItApp::OnInit() // MFC calls this InitInstance()
m_pServer = (AI_Server*)NULL;
m_bkSlash = _T("\\");
m_bSelectionChange = FALSE; // init - used in KB Sharing Mgr
m_bSuppressDropDown = FALSE; // FALSE is default value, wanted for allowing dropdown list to be dropped.
// But a TRUE value needs to do a once-only suppression of the opening, then set the bool back to FALSE
const wxString name = wxString::Format(_T("Adapt_ItApp-%s"), wxGetUserId().c_str());
// on my Windows machine name = "Adapt_ItApp-Bill Martin"
// on my Linux machine name = "Adapt_ItApp-wmartin"
Expand Down
13 changes: 13 additions & 0 deletions source/Adapt_It.h
Original file line number Diff line number Diff line change
Expand Up @@ -2381,6 +2381,19 @@ class CAdapt_ItApp : public wxApp
// global from the App.
//bool b_Spurious_Enter_Tab_Propagated;

// BEW 13jUL24 added, so that if the user accesses some other function, such as KB Editor,
// ChooseTranslation dialog, Preferences, does something there then returns to the focused
// location - the Phrasebox, and the Phrasebox has 2 or more items in the dropdown list,
// we can use a TRUE value of this new boolean to suppress dropping down the list. Why?
// The list is auto-dropped down, obscures part of next strip, and this is rarely what the
// user would want. E.g. it's a big nuisance when I do free translation, because I access
// the KB Editor lots of times and I don't want to have to close the drop down after I return
// having found out the info I want from the KB Editor. A FALSE value of this boolean just
// lets the legacy normal behaviour happen. The suppression is done in SetFocusAndSetSelectionAtLanding()
// and possibly may be needed in what follows that, the event.Skip() function.
// and possibly may be needed in what follows that, the event.Skip() function.
bool m_bSuppressDropDown;

// whm 15Apr2019 added the following m_nDropDownClickedItemIndex member in order to
// correct index of a clicked on item if a sudden scroll at left-click would cause
// a wrong index value for the item user intended to click on. It is initialized
Expand Down
7 changes: 7 additions & 0 deletions source/Adapt_ItView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19013,6 +19013,13 @@ void CAdapt_ItView::OnToolsKbEditor(wxCommandEvent& WXUNUSED(event))
int len = pApp->m_targetPhrase.Length();
pApp->m_nStartChar = len;
pApp->m_nEndChar = len;

// BEW experiment: suppress having the dropdown dropped down when returning from
// having the KB Editor opened.
// Turn off my changes, by setting next line FALSE, until more development is to be done
pApp->m_bSuppressDropDown = FALSE; // next line is the only place where set TRUE, currently
//pApp->m_bSuppressDropDown = TRUE; // The call in next line uses the TRUE value to skip over dropping
// down the list, when 2 or more entries are in the list
pApp->m_pTargetBox->SetFocusAndSetSelectionAtLanding();// whm 13Aug2018 modified
}
}
Expand Down
14 changes: 14 additions & 0 deletions source/Layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,20 @@ void CLayout::PlaceBox(enum placeBoxSetup placeboxsetup)
// the dropdown phrasebox list, so I'm here commenting out the m_bDrafting test.
//if (m_pApp->m_bDrafting)

// BEW experiment 13Jul24, if m_pApp->m_bSuppressDropDown is TRUE, avoid calling SetupDropDownPhraseBoxForThisLocation();
// because on return from might have nothing changed in KB, but if something was changed, I'd need to do more. But
// let's see if returning here, after clearing boolean, gives no dropdown of list. Yep, it succeeds - the list was not
// opened. What remains is to provide code that would update the list contents if KB Editor changes values for what's
// at the active location - changes at items in the KB Editor which is not pointing at the active location can be accepted
// and stored permanently - it's only when in the Editor we are looking at what the phrasebox's list needs to be changed.
// Probably we can grab from code further below to do that, we then just need to avoid opening the list - even though we've
// updated its contents. TODO... maybe Bill can take this further.
if (m_pApp->m_bSuppressDropDown)
{
m_pApp->m_bSuppressDropDown = FALSE;
return;
}

if (placeboxsetup == initializeDropDown)
{
m_pApp->m_pTargetBox->SetupDropDownPhraseBoxForThisLocation();
Expand Down
20 changes: 18 additions & 2 deletions source/PhraseBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9681,8 +9681,23 @@ void CPhraseBox::SetFocusAndSetSelectionAtLanding()
// View menu's 'Select Copied Source' toggle menu item.
int len = this->GetTextCtrl()->GetValue().Length();
// Never select phrasebox contents when there a > 1 items in list.
if (this->GetDropDownList()->GetCount() > 1)
{

// BEW 13Jul24 experiment: skip dropping down the list if KB Editor has set
// pApp->m_bSuppressDropDown to TRUE
CMyListBox* pMyDropdownList = this->GetDropDownList();
int listCount = pMyDropdownList->GetCount();
//if (this->GetDropDownList()->GetCount() > 1)
if (gpApp->m_bSuppressDropDown == TRUE)
{
int halt_here = 1;
// trace from here to find where the drop down is asked to drop...
//gpApp->m_bSuppressDropDown = FALSE; // restore default
return;
}

if(listCount > 1)
{

// The dropdown list has more than one item so it will be open and displaying its
// list items. In this situation we set the cursor to the end of the text, but
// not during editing - i.e., within the OnPhraseBoxChanged(), otherwise the cursor
Expand Down Expand Up @@ -9712,4 +9727,5 @@ void CPhraseBox::SetFocusAndSetSelectionAtLanding()
else
this->GetTextCtrl()->SetSelection(len, len); // Set insertion point at end of text.
}

}

0 comments on commit 75ddd7a

Please sign in to comment.