Created
April 30, 2010 17:13
-
-
Save trxcllnt/385495 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.voyager.clubhouse.modules.admin.view.components.passage.display.interaction | |
{ | |
import com.voyager.common.view.components.text.interaction.AbstractTextDispatcher; | |
import com.voyager.common.view.components.text.interaction.LineInfo; | |
import flash.events.MouseEvent; | |
import flash.geom.Point; | |
import flash.geom.Rectangle; | |
import flash.text.engine.TextLine; | |
import flash.ui.Mouse; | |
import flash.ui.MouseCursor; | |
public class WordTextBehavior extends AbstractTextDispatcher | |
{ | |
public function WordTextBehavior() | |
{ | |
super(); | |
} | |
override protected function mouseMoveHandler(event:MouseEvent):void | |
{ | |
super.mouseMoveHandler(event); | |
Mouse.cursor = MouseCursor.BUTTON; | |
var info:LineInfo = LineInfo.getInfo(event, this); | |
if(!info) | |
return; | |
info.container.blockFactory.decorator.flushDecorations(); | |
var index:int = info.line.getAtomIndexAtPoint(event.stageX, event.stageY); | |
var center:Number = info.line.getAtomCenter(index); | |
var p:Point = info.line.globalToLocal(new Point(event.stageX, event.stageY)); | |
if(p.x <= center && index > 0) | |
{ | |
index--; | |
} | |
if(index < 0) | |
return; | |
var rect:Rectangle = info.line.getAtomBounds(index); | |
rect.x += rect.width - 1.5; | |
rect.width = 3; | |
rect.y = info.line.y - rect.height; | |
info.container.blockFactory.decorator.addDecoration(rect, "backgroundColor", ".passageWordOver"); | |
} | |
override protected function mouseOutHandler(event:MouseEvent):void | |
{ | |
super.mouseOutHandler(event); | |
Mouse.cursor = MouseCursor.ARROW; | |
var info:LineInfo = LineInfo.getInfo(event, this); | |
if(!info) | |
return; | |
info.container.blockFactory.decorator.removeStyle(info.element); | |
info.container.blockFactory.decorator.addStyle(info.element, ".passageWord"); | |
} | |
override protected function mouseUpHandler(event:MouseEvent):void | |
{ | |
super.mouseUpHandler(event); | |
var info:LineInfo = LineInfo.getInfo(event); | |
if(!info) | |
return; | |
trace(info.element.text); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment