Osiris icon indicating copy to clipboard operation
Osiris copied to clipboard

menu elements clamping

Open mr-nv opened this issue 7 years ago • 3 comments

it would be nice to add clamping to menu elements to prevent something like this: clamping (to do that hold ctrl before clicking on an element)

mr-nv avatar May 22 '19 19:05 mr-nv

wtf? why dont u stop pressing ctrl before clicking on an element? i think it is a useless ask x.x kkk

ViniciusSchifferGuedes avatar May 22 '19 22:05 ViniciusSchifferGuedes

Sometimes you can do it by accident. So im up for this also.

sirxsniper avatar May 23 '19 05:05 sirxsniper

First version(not bad but not perfect)

sometimes it doesn't work

static LRESULT __stdcall hookedWndProc(HWND window, UINT msg, WPARAM wParam, LPARAM lParam) noexcept
{
	if (msg == WM_KEYDOWN && LOWORD(wParam) == config.misc.menuKey) {
		gui.isOpen = !gui.isOpen;
		if (!gui.isOpen) {
			ImGui::GetIO().MouseDown[0] = false;
			interfaces.inputSystem->resetInputState();
		}
	}
	if (gui.isOpen)
	{
		if ((msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) && wParam & MK_CONTROL)
			return CallWindowProc(hooks.originalWndProc, window, msg, wParam, lParam);

		if (!ImGui_ImplWin32_WndProcHandler(window, msg, wParam, lParam))
		{
			return true;
		}
	}
	return CallWindowProc(hooks.originalWndProc, window, msg, wParam, lParam);
}

Second version(perfect)

  1. Open imgui_widgets.cpp
  2. Find function https://github.com/danielkrupinski/Osiris/blob/084507d93206bf6129854b460aecf88acb7ab8b1/Osiris/imgui/imgui_widgets.cpp#L2391
  3. In this function delete this
if (start_text_input || (g.ActiveId == id && g.ScalarAsInputTextId == id))
    {
        window->DC.CursorPos = frame_bb.Min;
        FocusableItemUnregister(window);
        return InputScalarAsWidgetReplacement(frame_bb, id, label, data_type, v, format);
    }

CovERUshKA avatar May 23 '19 14:05 CovERUshKA