Class: Twiddler::Config::MouseChord

Inherits:
Chord
  • Object
show all
Defined in:
lib/twiddler/config.rb

Instance Attribute Summary collapse

Attributes inherited from Chord

#rows

Instance Method Summary collapse

Methods inherited from Chord

#extract_key, #keydata=, #render, #render_keys

Constructor Details

#initializeMouseChord

Returns a new instance of MouseChord.



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/twiddler/config.rb', line 313

def initialize
  super
  @mods = {
    :ctrl => false,
    :alt => false,
    :shift => false,
    :double => false,
    :toggle => false
  }
  @buttons = {
    :left => false,
    :middle => false,
    :right => false
  }
end

Instance Attribute Details

#buttonsObject (readonly)

Returns the value of attribute buttons.



329
330
331
# File 'lib/twiddler/config.rb', line 329

def buttons
  @buttons
end

#modsObject (readonly)

Returns the value of attribute mods.



329
330
331
# File 'lib/twiddler/config.rb', line 329

def mods
  @mods
end

Instance Method Details

#data=(bits) ⇒ Object



331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/twiddler/config.rb', line 331

def data=(bits)
  if bits[0] == ?1
    @mods[:ctrl] = true
  end
  if bits[1] == ?1 
    @mods[:alt] = true
  end
  if bits[2] == ?1 
    @mods[:shift] = true
  end
  if bits[3] == ?1 
    @mods[:double] = true
  end
  if bits[4] == ?1 
    @mods[:toggle] = true
  end
  if bits[5] == ?1 
    @buttons[:middle] = true
  end
  if bits[6] == ?1 
    @buttons[:right] = true
  end
  if bits[7] == ?1 
    @buttons[:left] = true
  end
end

#render_actionObject



358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# File 'lib/twiddler/config.rb', line 358

def render_action
  action = ""
  if @mods[:ctrl]
    action << "Ctl-"
  end
  if @mods[:alt]
    action << "Alt-"
  end
  if @mods[:shift]
    action << "Shf-"
  end
  if @mods[:double]
    action << "Dbl-"
  end
  if @mods[:toggle]
    action << "Tgl-"
  end
  if @buttons[:middle]
    action << "M"
  end
  if @buttons[:right]
    action << "R"
  end
  if @buttons[:left]
    action << "L"
  end
  return action
end