Author Topic: Compiler settings invalid path query - add pop up or leave like it is  (Read 10230 times)

Offline AndrewCot

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 678
If the dev enters an invalid path for the compiler manually or by selecting a wrong directory the current code allows the user to do this and on the next CB start shows the auto-detection dialog because the compiler is configured incorrectly.

I can add the following for when the masterpath focus is lost, which works correctly w.r.t calling the CompilerOptionsDlg::OnMasterPathKillFocus function.
Code
    // Setup on focus kill on masterpath to validate manual updates.
    XRCCTRL(*this, "txtMasterPath", wxTextCtrl)->Connect(wxEVT_KILL_FOCUS, wxFocusEventHandler(CompilerOptionsDlg::OnMasterPathKillFocus), NULL, this);

The OnMasterPathKillFocus could look like the following with more checking added like in the auto detection code as this is a P.O.C. for adding in the kill focus and a pop up, but it currently has an issue where the focus is left on the control you clicked on, but it is like the left mouse button is selected and there is no flashing icon in the text controls if you selected one. 
Code
void CompilerOptionsDlg::OnMasterPathKillFocus(wxFocusEvent& event)
{
    wxTextCtrl *wtcMasterPath  = wxDynamicCast(event.GetEventObject(), wxTextCtrl);
    wxString path = wtcMasterPath->GetValue();
    if (path.IsEmpty() || !wxDirExists(path)) // NEED TO ADD CHECK FOR BIN/{compiler file} LIKE auto detect code!!!!
    {
        switch(cbMessageBox(_("You have entered an invalid compiler [YOUR ANSWER IS ALREADY THERE. SEARCH THE FORUMS!] path. Do you want use this path?\n\n"
                                "Yes    : will save the invalid path\n"
                                "No     : will not save and allow you to change the path\n"),
                            _("invalid compiler [YOUR ANSWER IS ALREADY THERE. SEARCH THE FORUMS!] path detected"),
                            wxICON_EXCLAMATION|wxYES|wxNO))
        {
            case wxID_YES :
                DoSaveCompilerPrograms();
                break;
            case wxID_NO :
            default:
                break;
        } // end switch
    }
    // THE FOLLOWING BLOCK DOES NOT WORK!!!!
    XRCCTRL(*this, "tabPrograms", wxPanel)->SetFocus();
    //XRCCTRL(*this, "tabPrograms", wxPanel)->Update();
    XRCCTRL(*this, "tabPrograms", wxPanel)->Update();

    event.Skip();
}

Do you think the concept of checking the compiler path at the point of entry like I am proposing above is a good idea or not?
If you think this is a good idea, but do not like the yes option then let me know or if there are any other changes you can think of let me know.
If you think this is a good idea then do you have any pointers or ideas on how or where I can look to fix the focus issue I would be very geatfull as I am not a wxwidget guru and have only done a simple simulation GUI in wxwidgets (a single dialog with may bee 30 controls) to simulate some poker machine peripherals like a ticket printer, bill acceptor and coin mechanism.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Do you think the concept of checking the compiler path at the point of entry like I am proposing above is a good idea or not?
Nope, these are done on EndModal or tab switch as a minimum.
Something like the check in the debugger settings for the debugger executables are better IMO.
But here I think we support expansion of variables, which are context dependent, so I don't think any checking is good idea.
Checking for empty is probably fine, but checking for direxists is questionable given the support for variable expansion.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline AndrewCot

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 678
Will go with the first line of your response as it contradicts the rest of the post and as such I will go with the first line it as it makes the easiest way forward.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
The first line depicts the minimal thing which might work for such feature. The seconds is what I'll try to do if I do it. The third describes why checking here is probably not a good idea at all. The forth is a clarification.

So where do you see contradiction?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]