sokoban.love/0067-paste_button

29 lines
739 B
Plaintext

paste_button = function(x, y, r)
local w = App.width('paste')+10
local x2, y2 = maybe_draw_overflow_button(x, y, w, r)
if Overflow_button then
-- overflow
if not Show_overflow then
return x, y
else
y = y2
end
end
button(Global_state, 'paste', {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)
love.graphics.rectangle('line', p.x,p.y, p.w,p.h, 2,2)
love.graphics.print('paste', p.x+5,p.y+2)
end,
onpress1 = function()
local s = App.get_clipboard()
Text.insert_text(Current_pane.editor_state, s)
end,
})
if Overflow_button then
-- we're past the overflow button; start drawing downward
return x, y+Line_height
else
return x+w+10, y
end
end