diff --git a/0006-on.mouse_press b/0006-on.mouse_press index 071e9df..54aa45f 100644 --- a/0006-on.mouse_press +++ b/0006-on.mouse_press @@ -27,6 +27,12 @@ on.mouse_press = function(x,y, mouse_button) edit.mouse_press(node.editor, x,y, mouse_button) return end + local button = on_button(x,y) + if button then + -- HERE + button.bg = {r=1,g=0,b=0} + A() + end -- pan surface Pan = {x=Viewport.x+x/Viewport.zoom,y=Viewport.y+y/Viewport.zoom} end \ No newline at end of file diff --git a/0007-on_text b/0007-on_text index e803734..78ff704 100644 --- a/0007-on_text +++ b/0007-on_text @@ -1,6 +1,6 @@ on_text = function(x,y) for _,node in ipairs(Surface) do - if node.type == 'text' then + if node.type == 'text' and not node.button then if x >= vx(node.x) and node.w and x < vx(node.x + node.w) then if y >= vy(node.y) and node.h and y < vy(node.y + node.h) then return node diff --git a/0010-initialize_editor b/0010-initialize_editor index a3d9169..f3eb1cd 100644 --- a/0010-initialize_editor +++ b/0010-initialize_editor @@ -4,6 +4,7 @@ initialize_editor = function(obj) local scaled_fontsize = scale(20) local scaled_lineheight = math.floor(scaled_fontsize*1.3) obj.editor = edit.initialize_state(Menu_bar_height + vy(obj.y), math.floor(vx(obj.x)), math.ceil(vx(obj.x+obj.w)), scaled_fontsize, scaled_lineheight) + obj.editor.filename = obj.filename obj.editor.lines = obj.data Text.redraw_all(obj.editor) end diff --git a/0116-mouse_press_on_surface b/0116-mouse_press_on_surface deleted file mode 100644 index 1b1690d..0000000 --- a/0116-mouse_press_on_surface +++ /dev/null @@ -1,18 +0,0 @@ -mouse_press_on_surface = function(x,y, mouse_button) - if Cursor_node then - Cursor_node.show_cursor = nil - Cursor_node = nil - end - if mouse_press_consumed_by_any_button_handler(HUD, x,y, mouse_button) then - return - end - local node = on_text(x,y) - if node then - -- position cursor in node - Cursor_node = node - edit.mouse_press(node.editor, x,y, mouse_button) - return - end - -- pan surface - Pan = {x=Viewport.x+x/Viewport.zoom,y=Viewport.y+y/Viewport.zoom} -end \ No newline at end of file diff --git a/0118-load_subtree b/0118-load_subtree index 73bdfdb..ade9c38 100644 --- a/0118-load_subtree +++ b/0118-load_subtree @@ -5,18 +5,19 @@ load_subtree = function(filename, out, depth) -- every item is a row consisting of two columns: -- one column of padding and another of text local row = cols(Inter_comment_spacing) + table.insert(out, row) table.insert(row.data, {type='rectangle', w=depth*Indent, h=0}) local item_stuff = rows() + table.insert(row.data, item_stuff) table.insert(item_stuff.data, item) table.insert(item_stuff.data, { type='text', data={{data='reply'}}, + button=true, name=filename, margin=20, bg=Reply_button_color, border=Reply_button_border_color, }) - table.insert(row.data, item_stuff) - table.insert(out, row) for i,reply_id in ipairs(item.metadata.replies) do local reply = load_subtree(reply_id, out, depth+1) end diff --git a/0120-initialize_item b/0120-initialize_item index 7d50a69..2c7aae4 100644 --- a/0120-initialize_item +++ b/0120-initialize_item @@ -11,4 +11,4 @@ initialize_item = function(filename, depth) result.metadata = load_metadata(filename) result.border = Border_color return result -end +end \ No newline at end of file diff --git a/0135-on_button b/0135-on_button new file mode 100644 index 0000000..bed44d4 --- /dev/null +++ b/0135-on_button @@ -0,0 +1,11 @@ +on_button = function(x,y, mouse_button) + for _,node in ipairs(Surface) do + if node.type == 'text' and node.button then + if x >= vx(node.x) and node.w and x < vx(node.x + node.w) then + if y >= vy(node.y) and node.h and y < vy(node.y + node.h) then + return node + end + end + end + end +end \ No newline at end of file