Method: Fox::Canvas::ShapeCanvas#onLeftBtnRelease

Defined in:
lib/fox16/canvas.rb

#onLeftBtnRelease(sender, sel, evt) ⇒ Object

Left button release



543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
# File 'lib/fox16/canvas.rb', line 543

def onLeftBtnRelease(sender, sel, evt)
  flg = @flags
  if enabled?
    ungrab
    @flags |= FLAG_UPDATE
    @flags &= ~(FLAG_PRESSED|FLAG_TRYDRAG|FLAG_LASSO|FLAG_DODRAG)

    # First chance callback
    return 1 if target && target.handle(self, MKUINT(message, SEL_LEFTBUTTONRELEASE), evt) != 0

    # Was dragging
    if (flg & FLAG_DODRAG) != 0
      handle(self, MKUINT(0, SEL_ENDDRAG), evt)
      return 1
    end

    # Must have pressed
    if (flg & FLAG_PRESSED) != 0
      # Change selection
      if @currentShape && @currentShape.enabled?
        deselectShape(@currentShape, true)
      end

      # Generate clicked callbacks
      if evt.click_count == 1
        handle(self, MKUINT(0, SEL_CLICKED), @currentShape)
      elsif evt.click_count == 2
        handle(self, MKUINT(0, SEL_DOUBLECLICKED), @currentShape)
      elseif evt.click_count == 3
        handle(self, MKUINT(0, SEL_TRIPLECLICKED), @currentShape)
      end

      # Generate command callback only when clicked on item
      if @currentShape && @currentShape.enabled?
        handle(self, MKUINT(0, SEL_COMMAND), @currentShape)
      end
      return 1
    end
    return 0
  end
end