I've agonized over conflicts between editor and script handlers for a while, but finally the solution occurred to me: to use the script's handlers, hide the editor. To use the editor's handlers, show the editor. The menu and settings are always active. This seems nice and consistent, easy to explain.
Mike Stein would prefer we just supported love.* handlers in scripts to minimize special cases and cognitive load for people. But I'd rather err on the side of being transparent about what's going on inside. As a compromise I'm supporting love.* names at least in addition to my rephrasings (which came about mostly because love.keychordpressed is just too much of a mouthful)
6DJMOJKEO5DIOEDV655SPA7C7HN2HXWMDJ7UF2CRDRBAF5YO3UEAC
OZ42YLXGXAQC3WJ7624AY7YOY4SWS7I62SA6NZS2KXWNNCBFF5EQC
FYX6DG22PU3RPDFXMTBBSNEEHG4USSW7QXBTKSRYMUOVW3LGQHCAC
ZOLCTAGUUMQQ4MOZNVUANNOGEHWS7BYDTIMP3ZABLYKWUSAAMMPQC
JV27LDDKKY57IEBWGBFPSHEARMOEGLBYGBJD27PDPTNWWYXA4T6AC
R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC
VAVXKWZVOFJGWHCWYLTPDKSKKMSJEBKXNKXUW3T6IZAC3HE6HOIQC
ZM7NOBRMD5HHA35Y4JDC76EOA2RD4KQOQCPURXYKXA6ABMKOJIGQC
IP4LD33DQFWQ4654YPNJRKQ3CNYSHRZPX6U6ZPY7OLE744XX3MEQC
5RUFNRJOK3PXQKJTPDEN5K5PI67MGB25QUA44WOCCH2O5KHXT45QC
Z5M23NTKKGEACSQJT27DRNS7NEK6OSLR2IOWVAH2C2PRAIU46BIQC
PRE6XPRNICDCHMF7C45A6DRPVT47IPAIWW6Q7AHNGW3D2PBGOPNAC
WR2WMEPEKNFAB4CAUBVFBACAJJSX2VX5B2VHKKSNTJSJBIIXFVZQC
RK2ASPN7A55RCEG2YRFZLFXNPSME2VKBE2ZXO257DYZPS5TPXC5QC
UEG224LHBOPWSKOVXTKVAUEL47HET566LJF7ZSWVKMMLBSJWUHFAC
on.mouse_wheel_move = function(dx,dy)
if Show_code then
-- nothing yet
else
-- editors hidden
if car.mouse_wheel_move then car.mouse_wheel_move(dx,dy) end
if car.wheelmoved then car.wheelmoved(dx,dy) end
end
end
-- Table where any handlers for the current pane will live.
car = {}
if Current_pane.editor_state.scrollbar_drag then
adjust_scrollbar(Current_pane.editor_state, y)
Current_pane.editor_state.scrollbar_drag = nil
elseif on_editor_scrollbar_area(Current_pane.editor_state, x,y) then
adjust_scrollbar(Current_pane.editor_state, y)
elseif x < Current_pane.editor_state.right + 15 - 5 and y < Current_pane.editor_state.bottom + 5 + 10 - 5 then
edit.mouse_release(Current_pane.editor_state, x,y, mouse_button)
elseif Current_pane.output_editor_state.scrollbar_drag then
adjust_scrollbar(Current_pane.output_editor_state, y)
Current_pane.output_editor_state.scrollbar_drag = nil
elseif on_editor_scrollbar_area(Current_pane.output_editor_state, x,y) then
adjust_scrollbar(Current_pane.output_editor_state, y)
if Show_code then
if Current_pane.editor_state.scrollbar_drag then
adjust_scrollbar(Current_pane.editor_state, y)
Current_pane.editor_state.scrollbar_drag = nil
elseif on_editor_scrollbar_area(Current_pane.editor_state, x,y) then
adjust_scrollbar(Current_pane.editor_state, y)
elseif x < Current_pane.editor_state.right + 15 - 5 and y < Current_pane.editor_state.bottom + 5 + 10 - 5 then
edit.mouse_release(Current_pane.editor_state, x,y, mouse_button)
elseif Current_pane.output_editor_state.scrollbar_drag then
adjust_scrollbar(Current_pane.output_editor_state, y)
Current_pane.output_editor_state.scrollbar_drag = nil
elseif on_editor_scrollbar_area(Current_pane.output_editor_state, x,y) then
adjust_scrollbar(Current_pane.output_editor_state, y)
end
else
-- editors hidden
if car.mouse_release then car.mouse_release(x,y, mouse_button) end
if car.mousereleased then car.mousereleased(x,y, mouse_button) end
if on_editor_scrollbar(Current_pane.editor_state, x,y) then
Current_pane.editor_state.scrollbar_drag = true
elseif on_editor_scrollbar_area(Current_pane.editor_state, x,y) then
-- nothing
elseif x < Current_pane.editor_state.right + 15 - 5 and y < Current_pane.editor_state.bottom + 5 + 10 - 5 then
love.keyboard.setTextInput(true)
edit.mouse_press(Current_pane.editor_state, x,y, mouse_button)
elseif on_editor_scrollbar(Current_pane.output_editor_state, x,y) then
Current_pane.output_editor_state.scrollbar_drag = true
elseif on_editor_scrollbar_area(Current_pane.output_editor_state, x,y) then
-- nothing
if Show_code then
if on_editor_scrollbar(Current_pane.editor_state, x,y) then
Current_pane.editor_state.scrollbar_drag = true
elseif on_editor_scrollbar_area(Current_pane.editor_state, x,y) then
-- nothing
elseif x < Current_pane.editor_state.right + 15 - 5 and y < Current_pane.editor_state.bottom + 5 + 10 - 5 then
love.keyboard.setTextInput(true)
edit.mouse_press(Current_pane.editor_state, x,y, mouse_button)
elseif on_editor_scrollbar(Current_pane.output_editor_state, x,y) then
Current_pane.output_editor_state.scrollbar_drag = true
elseif on_editor_scrollbar_area(Current_pane.output_editor_state, x,y) then
-- nothing
end
else
-- editors hidden
if car.mouse_press then car.mouse_press(x,y, mouse_button) end
if car.mousepressed then car.mousepressed(x,y, mouse_button) end
if Current_pane.editor_state.cursor_x then
edit.key_release(Current_pane.editor_state, key, scancode)
if Show_code then
if Current_pane.editor_state.cursor_x then
edit.key_release(Current_pane.editor_state, key, scancode)
end
else
-- editors hidden
if car.key_release then car.key_release(key, scancode) end
if car.keyreleased then car.keyreleased(key, scancode) end
if Current_pane.editor_state.cursor_x then
edit.text_input(Current_pane.editor_state, t)
if Show_code then
if Current_pane.editor_state.cursor_x then
edit.text_input(Current_pane.editor_state, t)
end
else
-- editors hidden
if car.text_input then car.text_input(t) end
if car.textinput then car.textinput(t) end
elseif Current_pane.editor_state.cursor_x then
-- send keys to editor if cursor is visible
edit.keychord_press(Current_pane.editor_state, chord, key)
elseif Show_code then
if Current_pane.editor_state.cursor_x then
-- send keys to editor if cursor is visible
edit.keychord_press(Current_pane.editor_state, chord, key)
end
else
-- editors hidden
if car.keychord_press then car.keychord_press(chord, key) end
if car.keypressed then car.keypressed(key) end