activate buttons for some time
The active state has 2 uses: * It gives some visual feedback that a button has been pressed. Otherwise, tapping a button gave no feedback that the tap had occurred. Particularly on a phone screen where fat-fingering is easier, hitting the 'save' button in particular gave no hint that the file had actually been saved. Which causes some anxiety. * It suppresses all mouse taps during the activation time. For example, this helps keep tapping say an overflow button from selecting text in the editor.
This commit is contained in:
parent
d85c246cfb
commit
0d2d85d8d7
|
@ -1,5 +1,8 @@
|
|||
on.update = function(dt)
|
||||
refresh_debug_animations()
|
||||
if Active_button and Active_button.expire <= Current_time then
|
||||
Active_button = nil
|
||||
end
|
||||
if App.mouse_down(1) then
|
||||
update_any_sliders(App.mouse_x(), App.mouse_y())
|
||||
end
|
||||
|
@ -9,4 +12,4 @@ on.update = function(dt)
|
|||
adjust_scrollbar(Current_pane.output_editor_state, App.mouse_y())
|
||||
end
|
||||
if car.update then call_protected(car.update, dt) end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
on.mouse_press = function(x,y, mouse_button)
|
||||
-- some hysteresis right after a button has been pressed
|
||||
if Active_button then return end
|
||||
if mouse_press_consumed_by_any_button_handler(Global_state, x,y, mouse_button) then
|
||||
return
|
||||
end
|
||||
|
|
|
@ -2,10 +2,20 @@ styled_button = function(name, x, y, onpress1)
|
|||
local w = App.width(name)+10
|
||||
button(Global_state, name, {x=x, y=y, w=w, h=Line_height, bg={r=0.6, g=0.8, b=0.6},
|
||||
icon = function(p)
|
||||
App.color(Normal_color)
|
||||
if Active_button and Active_button.name == name and Active_button.expire > Current_time then
|
||||
App.color(Highlighted_button_color)
|
||||
else
|
||||
App.color(Normal_color)
|
||||
end
|
||||
love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
|
||||
love.graphics.print(name, p.x+5,p.y+2)
|
||||
end,
|
||||
onpress1 = onpress1,
|
||||
onpress1 = function()
|
||||
onpress1()
|
||||
Active_button = {
|
||||
name=name,
|
||||
expire=Current_time+0.1,
|
||||
}
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Highlighted_button_color = {r=1, g=1, b=1}
|
|
@ -0,0 +1,3 @@
|
|||
Active_button = nil
|
||||
-- When a button is pressed:
|
||||
-- {name=..., expire=...}
|
Loading…
Reference in New Issue