Skip to content

Commit b4651ed

Browse files
committed
Added a couple lines of code to suppress the opening of the phrasebox's dropdown list when exiting free translation mode, and also added the same two lines to suppress the dropdown list when exiting the KB Editor and Choose Translation dialogs.
Removed BEW's test code that intended to do the same job but was unsuccessful.
1 parent c7b6474 commit b4651ed

File tree

6 files changed

+15
-55
lines changed

6 files changed

+15
-55
lines changed

source/Adapt_It.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -24160,8 +24160,6 @@ bool CAdapt_ItApp::OnInit() // MFC calls this InitInstance()
2416024160
m_pServer = (AI_Server*)NULL;
2416124161
m_bkSlash = _T("\\");
2416224162
m_bSelectionChange = FALSE; // init - used in KB Sharing Mgr
24163-
m_bSuppressDropDown = FALSE; // FALSE is default value, wanted for allowing dropdown list to be dropped.
24164-
// But a TRUE value needs to do a once-only suppression of the opening, then set the bool back to FALSE
2416524163
const wxString name = wxString::Format(_T("Adapt_ItApp-%s"), wxGetUserId().c_str());
2416624164
// on my Windows machine name = "Adapt_ItApp-Bill Martin"
2416724165
// on my Linux machine name = "Adapt_ItApp-wmartin"

source/Adapt_It.h

-13
Original file line numberDiff line numberDiff line change
@@ -2381,19 +2381,6 @@ class CAdapt_ItApp : public wxApp
23812381
// global from the App.
23822382
//bool b_Spurious_Enter_Tab_Propagated;
23832383

2384-
// BEW 13jUL24 added, so that if the user accesses some other function, such as KB Editor,
2385-
// ChooseTranslation dialog, Preferences, does something there then returns to the focused
2386-
// location - the Phrasebox, and the Phrasebox has 2 or more items in the dropdown list,
2387-
// we can use a TRUE value of this new boolean to suppress dropping down the list. Why?
2388-
// The list is auto-dropped down, obscures part of next strip, and this is rarely what the
2389-
// user would want. E.g. it's a big nuisance when I do free translation, because I access
2390-
// the KB Editor lots of times and I don't want to have to close the drop down after I return
2391-
// having found out the info I want from the KB Editor. A FALSE value of this boolean just
2392-
// lets the legacy normal behaviour happen. The suppression is done in SetFocusAndSetSelectionAtLanding()
2393-
// and possibly may be needed in what follows that, the event.Skip() function.
2394-
// and possibly may be needed in what follows that, the event.Skip() function.
2395-
bool m_bSuppressDropDown;
2396-
23972384
// whm 15Apr2019 added the following m_nDropDownClickedItemIndex member in order to
23982385
// correct index of a clicked on item if a sudden scroll at left-click would cause
23992386
// a wrong index value for the item user intended to click on. It is initialized

source/Adapt_ItView.cpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -15968,11 +15968,13 @@ void CAdapt_ItView::OnButtonChooseTranslation(wxCommandEvent& WXUNUSED(event))
1596815968
//int saveBoolean = pApp->m_bTypedNewAdaptationInChooseTranslation;
1596915969
GetLayout()->PlaceBox(); // might not be needed? No it is needed - otherwise it rebuids list on
1597015970
// where I move phrasebox too & adds old locations meanings to the list there. Ouch.
15971-
1597215971
// I didn't notice the next line, that clobbers the boolean too early - so is probably why I
1597315972
// got the error. Commenting it out should suffice
1597415973
//pApp->m_bTypedNewAdaptationInChooseTranslation = FALSE; // gotta restore initialized value before leaving here
1597515974

15975+
pApp->m_pTargetBox->CloseDropDown(); // whm 16July2024 added to suppress the opening of the dropdown list on exit from free trans mode
15976+
pApp->m_bChooseTransInitializePopup = FALSE; // whm 16July2024 added to suppress the opening of the dropdown list on exit from free trans mode
15977+
1597615978
#if defined (_DEBUG)
1597715979
wxLogDebug(_T("view, OnButtonChooseTranslation, line %d returning, at end simpler code block, pApp->m_bTypedNewAdaptationInChooseTranslation = %d"), __LINE__,
1597815980
(int)pApp->m_bTypedNewAdaptationInChooseTranslation);
@@ -16053,7 +16055,11 @@ void CAdapt_ItView::OnButtonChooseTranslation(wxCommandEvent& WXUNUSED(event))
1605316055
// it is needed.
1605416056
// TODO: Determine if there really is a need for the PlaceBox() call here within the OnButtonChooseTranslation()
1605516057
// handler.
16056-
pApp->m_pTargetBox->m_Translation.Empty(); // If the PlaceBox() call can be removed, this can go back into Layout's PlaceBox() after the PopulateDropDownList() call
16058+
16059+
pApp->m_pTargetBox->CloseDropDown(); // whm 16July2024 added to suppress the opening of the dropdown list on exit from free trans mode
16060+
pApp->m_bChooseTransInitializePopup = FALSE; // whm 16July2024 added to suppress the opening of the dropdown list on exit from free trans mode
16061+
16062+
pApp->m_pTargetBox->m_Translation.Empty(); // If the PlaceBox() call can be removed, this can go back into Layout's PlaceBox() after the PopulateDropDownList() call
1605716063
#if defined (_DEBUG)
1605816064
wxLogDebug(_T("view, OnButtonChooseTranslation, line %d End legacy code block, pApp->m_bTypedNewAdaptationInChooseTranslation = %d"), __LINE__,
1605916065
(int)pApp->m_bTypedNewAdaptationInChooseTranslation);
@@ -19013,13 +19019,6 @@ void CAdapt_ItView::OnToolsKbEditor(wxCommandEvent& WXUNUSED(event))
1901319019
int len = pApp->m_targetPhrase.Length();
1901419020
pApp->m_nStartChar = len;
1901519021
pApp->m_nEndChar = len;
19016-
19017-
// BEW experiment: suppress having the dropdown dropped down when returning from
19018-
// having the KB Editor opened.
19019-
// Turn off my changes, by setting next line FALSE, until more development is to be done
19020-
pApp->m_bSuppressDropDown = FALSE; // next line is the only place where set TRUE, currently
19021-
//pApp->m_bSuppressDropDown = TRUE; // The call in next line uses the TRUE value to skip over dropping
19022-
// down the list, when 2 or more entries are in the list
1902319022
pApp->m_pTargetBox->SetFocusAndSetSelectionAtLanding();// whm 13Aug2018 modified
1902419023
}
1902519024
}
@@ -19044,6 +19043,9 @@ void CAdapt_ItView::OnToolsKbEditor(wxCommandEvent& WXUNUSED(event))
1904419043
// enum internally and calls the SetupDropDownPhraseBoxForThisLocation() to initialize the dropdown
1904519044
// list - to include any changes made in the editor.
1904619045
GetLayout()->PlaceBox(); // this call probably unneeded but no harm done
19046+
pApp->m_pTargetBox->CloseDropDown(); // whm 16July2024 added to suppress the opening of the dropdown list on exit from free trans mode
19047+
pApp->m_bChooseTransInitializePopup = FALSE; // whm 16July2024 added to suppress the opening of the dropdown list on exit from free trans mode
19048+
1904719049
//#if defined (_DEBUG)
1904819050
// wxLogDebug(_T("view, OnToolsKbEditor, line %d - AFTER PlaceBox, pApp->m_targetPhrase = %s phrasebox = %s ctItems = %d"), __LINE__,
1904919051
// pApp->m_targetPhrase.c_str(), pApp->m_pTargetBox->GetTextCtrl()->GetValue().c_str(), pApp->m_pTargetBox->GetDropDownList()->GetCount());

source/Layout.cpp

-14
Original file line numberDiff line numberDiff line change
@@ -1163,20 +1163,6 @@ void CLayout::PlaceBox(enum placeBoxSetup placeboxsetup)
11631163
// the dropdown phrasebox list, so I'm here commenting out the m_bDrafting test.
11641164
//if (m_pApp->m_bDrafting)
11651165

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

source/MainFrm.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -4656,6 +4656,8 @@ void CMainFrame::OnIdle(wxIdleEvent& event)
46564656
CCell* pCell = pApp->m_pActivePile->GetCell(1);
46574657
int activeSN = pApp->m_pActivePile->GetSrcPhrase()->m_nSequNumber;
46584658
pView->PlacePhraseBox(pCell,1);
4659+
pApp->m_pTargetBox->CloseDropDown(); // whm 16July2024 added to suppress the opening of the dropdown list on exit from free trans mode
4660+
pApp->m_bChooseTransInitializePopup = FALSE; // whm 16July2024 added to suppress the opening of the dropdown list on exit from free trans mode
46594661
pApp->m_pActivePile = pView->GetPile(activeSN); // restore active pile ptr
46604662
pView->Invalidate();
46614663
}

source/PhraseBox.cpp

+2-17
Original file line numberDiff line numberDiff line change
@@ -9681,23 +9681,8 @@ void CPhraseBox::SetFocusAndSetSelectionAtLanding()
96819681
// View menu's 'Select Copied Source' toggle menu item.
96829682
int len = this->GetTextCtrl()->GetValue().Length();
96839683
// Never select phrasebox contents when there a > 1 items in list.
9684-
9685-
// BEW 13Jul24 experiment: skip dropping down the list if KB Editor has set
9686-
// pApp->m_bSuppressDropDown to TRUE
9687-
CMyListBox* pMyDropdownList = this->GetDropDownList();
9688-
int listCount = pMyDropdownList->GetCount();
9689-
//if (this->GetDropDownList()->GetCount() > 1)
9690-
if (gpApp->m_bSuppressDropDown == TRUE)
9691-
{
9692-
int halt_here = 1;
9693-
// trace from here to find where the drop down is asked to drop...
9694-
//gpApp->m_bSuppressDropDown = FALSE; // restore default
9695-
return;
9696-
}
9697-
9698-
if(listCount > 1)
9684+
if (this->GetDropDownList()->GetCount() > 1)
96999685
{
9700-
97019686
// The dropdown list has more than one item so it will be open and displaying its
97029687
// list items. In this situation we set the cursor to the end of the text, but
97039688
// not during editing - i.e., within the OnPhraseBoxChanged(), otherwise the cursor
@@ -9727,5 +9712,5 @@ void CPhraseBox::SetFocusAndSetSelectionAtLanding()
97279712
else
97289713
this->GetTextCtrl()->SetSelection(len, len); // Set insertion point at end of text.
97299714
}
9730-
9715+
97319716
}

0 commit comments

Comments
 (0)