Class: GTK::Mouse

Inherits:
Object show all
Extended by:
Docs, MouseDocs
Defined in:
dragon/inputs.rb,
dragon/mouse_docs.rb

Overview

Provides access to the mouse.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MouseDocs

docs_class

Methods included from Docs

__docs_append_true_line__, __docs_line_to_html__, __docs_search__, __docs_search_help_text__, __docs_search_results__, __docs_to_html__, __export_docs__!, docs, docs_all, docs_classes, docs_method_sort_order, docs_search, export_docs!, extended

Constructor Details

#initializeMouse

Returns a new instance of Mouse.


503
504
505
506
507
508
509
510
511
512
513
514
# File 'dragon/inputs.rb', line 503

def initialize
  @x = 0
  @y = 0
  @has_focus = false
  @button_bits = 0
  @button_left = false
  @button_middle = false
  @button_right = false
  @button_x1 = false
  @button_x2 = false
  clear
end

Instance Attribute Details

#button_bitsObject

Returns the value of attribute button_bits


489
490
491
# File 'dragon/inputs.rb', line 489

def button_bits
  @button_bits
end

#button_leftObject

Returns the value of attribute button_left


489
490
491
# File 'dragon/inputs.rb', line 489

def button_left
  @button_left
end

#button_middleObject

Returns the value of attribute button_middle


489
490
491
# File 'dragon/inputs.rb', line 489

def button_middle
  @button_middle
end

#button_rightObject

Returns the value of attribute button_right


489
490
491
# File 'dragon/inputs.rb', line 489

def button_right
  @button_right
end

#button_x1Object

Returns the value of attribute button_x1


489
490
491
# File 'dragon/inputs.rb', line 489

def button_x1
  @button_x1
end

#button_x2Object

Returns the value of attribute button_x2


489
490
491
# File 'dragon/inputs.rb', line 489

def button_x2
  @button_x2
end

#clickObject

Returns the value of attribute click


498
499
500
# File 'dragon/inputs.rb', line 498

def click
  @click
end

#global_moved_atObject

Returns the value of attribute global_moved_at


489
490
491
# File 'dragon/inputs.rb', line 489

def global_moved_at
  @global_moved_at
end

#has_focusObject

Returns the value of attribute has_focus


489
490
491
# File 'dragon/inputs.rb', line 489

def has_focus
  @has_focus
end

#movedObject

Returns the value of attribute moved


489
490
491
# File 'dragon/inputs.rb', line 489

def moved
  @moved
end

#moved_atObject

Returns the value of attribute moved_at


489
490
491
# File 'dragon/inputs.rb', line 489

def moved_at
  @moved_at
end

#previous_clickObject

Returns the value of attribute previous_click


499
500
501
# File 'dragon/inputs.rb', line 499

def previous_click
  @previous_click
end

#upObject

Returns the value of attribute up


489
490
491
# File 'dragon/inputs.rb', line 489

def up
  @up
end

#wheelObject

Returns the value of attribute wheel


489
490
491
# File 'dragon/inputs.rb', line 489

def wheel
  @wheel
end

#xObject

Returns the value of attribute x


500
501
502
# File 'dragon/inputs.rb', line 500

def x
  @x
end

#yObject

Returns the value of attribute y


501
502
503
# File 'dragon/inputs.rb', line 501

def y
  @y
end

Instance Method Details

#clearObject


534
535
536
537
538
539
540
541
542
543
544
545
# File 'dragon/inputs.rb', line 534

def clear
  if @click
    @previous_click = MousePoint.new @click.point.x, @click.point.y
    @previous_click.created_at = @click.created_at
    @previous_click.global_created_at = @click.global_created_at
  end

  @click = nil
  @up    = nil
  @moved = nil
  @wheel = nil
end

#downObject


551
552
553
# File 'dragon/inputs.rb', line 551

def down
  @click
end

#inside_circle?(center, radius) ⇒ Boolean

Returns:

  • (Boolean)

524
525
526
# File 'dragon/inputs.rb', line 524

def inside_circle? center, radius
  point.point_inside_circle? center, radius
end

#inside_rect?(rect) ⇒ Boolean

Returns:

  • (Boolean)

520
521
522
# File 'dragon/inputs.rb', line 520

def inside_rect? rect
  point.inside_rect? rect
end

#intersect_rect?(other_rect) ⇒ Boolean

Returns:

  • (Boolean)

528
529
530
# File 'dragon/inputs.rb', line 528

def intersect_rect? other_rect
  { x: point.x, y: point.y, w: 0, h: 0 }.intersect_rect? other_rect
end

#pointObject Also known as: position


516
517
518
# File 'dragon/inputs.rb', line 516

def point
  [@x, @y].point
end

#serializeObject


555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
# File 'dragon/inputs.rb', line 555

def serialize
  result = {}

  if @click
    result[:click] = @click.to_hash
    result[:down] = @click.to_hash
  end

  result[:up] = @up.to_hash if @up
  result[:x] = @x
  result[:y] = @y
  result[:moved] = @moved
  result[:moved_at] = @moved_at
  result[:has_focus] = @has_focus

  result
end

#to_sObject Also known as: inspect


573
574
575
# File 'dragon/inputs.rb', line 573

def to_s
  serialize.to_s
end