mirror of
https://github.com/mattrberry/crab.git
synced 2025-01-29 20:35:13 +01:00
auto-increment selection, don't capture when window is closed
This commit is contained in:
parent
40b485780c
commit
692a25800e
1 changed files with 4 additions and 3 deletions
|
@ -30,14 +30,14 @@ module ImGui
|
||||||
end
|
end
|
||||||
|
|
||||||
def wants_input? : Bool
|
def wants_input? : Bool
|
||||||
!@selection.nil?
|
@open && !@selection.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def key_released(keycode : LibSDL::Keycode) : Nil
|
def key_released(keycode : LibSDL::Keycode) : Nil
|
||||||
if selection = @selection
|
if selection = @selection
|
||||||
@editing_keycodes.reject!(@editing_keycodes.key_for?(selection))
|
@editing_keycodes.reject!(@editing_keycodes.key_for?(selection))
|
||||||
@editing_keycodes[keycode] = selection
|
@editing_keycodes[keycode] = selection
|
||||||
@selection = nil
|
@selection = Input.from_value?(selection.value + 1)
|
||||||
else
|
else
|
||||||
puts "Something went wrong when setting keybinding.."
|
puts "Something went wrong when setting keybinding.."
|
||||||
end
|
end
|
||||||
|
@ -53,7 +53,7 @@ module ImGui
|
||||||
ImGui.set_next_window_pos(center, ImGui::ImGuiCond::Appearing, ImGui::ImVec2.new(0.5, 0.5))
|
ImGui.set_next_window_pos(center, ImGui::ImGuiCond::Appearing, ImGui::ImVec2.new(0.5, 0.5))
|
||||||
hovered_button_color = ImGui.get_style_color_vec4(ImGui::ImGuiCol::ButtonHovered)
|
hovered_button_color = ImGui.get_style_color_vec4(ImGui::ImGuiCol::ButtonHovered)
|
||||||
if ImGui.begin_popup_modal(POPUP_NAME, flags: ImGui::ImGuiWindowFlags::AlwaysAutoResize)
|
if ImGui.begin_popup_modal(POPUP_NAME, flags: ImGui::ImGuiWindowFlags::AlwaysAutoResize)
|
||||||
Input.values.each do |input|
|
Input.each do |input|
|
||||||
selected = @selection == input
|
selected = @selection == input
|
||||||
keycode = @editing_keycodes.key_for?(input)
|
keycode = @editing_keycodes.key_for?(input)
|
||||||
button_text = keycode ? String.new(LibSDL.get_key_name(keycode)) : ""
|
button_text = keycode ? String.new(LibSDL.get_key_name(keycode)) : ""
|
||||||
|
@ -86,6 +86,7 @@ module ImGui
|
||||||
|
|
||||||
private def close : Nil
|
private def close : Nil
|
||||||
@open = false
|
@open = false
|
||||||
|
@selection = nil
|
||||||
ImGui.close_current_popup
|
ImGui.close_current_popup
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue