ImTerm icon indicating copy to clipboard operation
ImTerm copied to clipboard

Can't hold focus on command input widget?

Open hippyau opened this issue 4 years ago • 3 comments

Hi there!

I have working well with spdlog integrated too, but there is one big problem... I can't enter any commands.

It seems like everytime I click to enter text into the command input, it only holds focus for 1 frame.

I can only get something into the command input box if I hold a key on the keyboard while clicking the input box.

The tool tip appears for a frame, then disappears, then focus is lost.

problem1-2021-02-13_161948-high

video of problem here

It appears related to the tool tip, because if I get a 'c' into the box (by holding c and clicking the input box to get focus) the problem continues, but once I have two 'c' in the box, it starts to work perfectly, presumably because there are no commands starting with 'cc'. To clarify, once I have got 'cc' into the text input then it behaves normally right up until I press enter, or backspace one 'c'. So seems like somehow the popup completion hint is stealing the focus before I can even try anything?

Using the ImGui 1.80, no compiler errors or warnings, I am using the example code as such...

I brought the ui_terminal_commands.* straight from the example, and in my draw loop....

// Terminal
    static custom_command_struct cmd_struct; // terminal commands can interact with this structure
    static ImTerm::terminal<terminal_commands> terminal_log(cmd_struct);
    static bool once = true;
    static bool showing_term = true;
    if (once){ // do this only once
        terminal_log.set_min_log_level(ImTerm::message::severity::info);
        spdlog::set_level(spdlog::level::trace);
        spdlog::default_logger()->sinks().push_back(terminal_log.get_terminal_helper());        
        once = false;
    }
    if (showing_term) {		
			showing_term = terminal_log.show();
			if (cmd_struct.should_close) {
				//window.close();  // quit?
			}
    }
    // End Terminal

hippyau avatar Feb 13 '21 06:02 hippyau

Hello

I will try to dig into this, unfortunately I won’t have much time until the end of february

In the mean time, you can try to revert back to imgui 1.74, which is the version I used when developping ImTerm, and see if that helps

Organic-Code avatar Feb 13 '21 09:02 Organic-Code

The Issue is the call to ImGui::SetNextWindowFocus() in show_autocomplete(). Commenting it out fixed the issue (at least on the docking branch of ImGui). I don't know however if that breaks anything else...

IcyTv avatar Aug 20 '21 01:08 IcyTv

This also happens with the basic_terminal_helper. Just commenting out that line fixes the issue. It is not fixed by #4

fabio-polystream avatar Apr 14 '23 14:04 fabio-polystream