about summary refs log tree commit diff stats
path: root/keychord.lua
Commit message (Expand)AuthorAgeFilesLines
* bugfix: typing a capital letter deletes selectionKartik K. Agaram2022-06-261-1/+1
* bugfix: don't delete selection when moving cursorKartik K. Agaram2022-06-231-0/+4
* stop generating invalid keychordsKartik K. Agaram2022-06-141-0/+1
* select text with shift + mouseclickKartik K. Agaram2022-06-041-5/+5
* regression: typing uppercase letters in textKartik K. Agaram2022-05-301-7/+6
* some helpersKartik K. Agaram2022-05-291-0/+16
* bugfix: include shift keys in modifier_downKartik K. Agaram2022-05-281-3/+25
* tweak modifier keys to include 'shift'Kartik K. Agaram2022-05-271-1/+4
* paste in text with M-vKartik K. Agaram2022-05-261-0/+5
* .Kartik K. Agaram2022-05-251-1/+0
* M-left/M-right for word-based motionsKartik K. Agaram2022-05-251-0/+1
* basic test-enabled frameworkKartik K. Agaram2022-05-221-3/+3
* handle chordsKartik K. Agaram2022-05-021-0/+25
e>8057f3e ^
8747415 ^
8057f3e ^
475bbd7 ^
490f10c ^
8747415 ^


490f10c ^
475bbd7 ^

8747415 ^
475bbd7 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

                                                                              





                                                                            
 
                                          



                                      

                                                                            
                                             
                                             


                                
                                                                              


                                      
                      
                                              
                                                             
                                               


                                 
         

       
               
   
-- Simple immediate-mode buttons with (currently) just an onpress1 handler for
-- the left button.
--
-- Buttons can nest in principle, though I haven't actually used that yet.
--
-- Don't rely on the order in which handlers are run. Within any widget, all
-- applicable button handlers will run. If _any_ of them returns true, the
-- event will continue to propagate elsewhere in the widget.

-- draw button and queue up event handlers
function button(State, name, params)
  if State.button_handlers == nil then
    State.button_handlers = {}
  end
  love.graphics.setColor(params.color[1], params.color[2], params.color[3])
  love.graphics.rectangle('fill', params.x,params.y, params.w,params.h, 5,5)
  if params.icon then params.icon(params) end
  table.insert(State.button_handlers, params)
end

-- process button event handlers
function mouse_press_consumed_by_any_button_handler(State, x, y, mouse_button)
  if State.button_handlers == nil then
    return
  end
  local result = false
  for _,ev in ipairs(State.button_handlers) do
    if x>ev.x and x<ev.x+ev.w and y>ev.y and y<ev.y+ev.h then
      if ev.onpress1 and mouse_button == 1 then
        if not ev.onpress1() then
          result = true
        end
      end
    end
  end
  return result
end