本文整理汇总了Java中com.jme3.input.event.MouseButtonEvent类的典型用法代码示例。如果您正苦于以下问题:Java MouseButtonEvent类的具体用法?Java MouseButtonEvent怎么用?Java MouseButtonEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MouseButtonEvent类属于com.jme3.input.event包,在下文中一共展示了MouseButtonEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDraggable
import com.jme3.input.event.MouseButtonEvent; //导入依赖的package包/类
private void createDraggable() {
if (inventoryItem.getItem() != null) {
addChild(draggable = new InventoryItemDraggable(dragContext, screen, inventoryAndEquipment, inventoryItem) {
@Override
protected boolean doOnDragEnd(MouseButtonEvent mbe, Element elmnt) {
try {
return doEndDraggableDrag(mbe, elmnt);
} finally {
screen.updateZOrder(LUtil.getRootElement(this));
}
}
@Override
protected boolean doOnClick(MouseButtonEvent evt) {
// Does nothing at the moment
return false;
}
});
}
}
示例2: doOnDragEnd
import com.jme3.input.event.MouseButtonEvent; //导入依赖的package包/类
@Override
public boolean doOnDragEnd(MouseButtonEvent mbe, Element elmnt) {
LOG.fine(String.format("Finished drag of %s on to %s", toString(), elmnt));
if (elmnt != null && elmnt instanceof InventoryItemDroppable && !elmnt.equals(getParent()) && inventoryAndEquipment.getFreeSlots() > 0) {
try {
InventoryItemDroppable droppable = (InventoryItemDroppable) elmnt;
inventoryAndEquipment.deequip(droppable.getInventoryItem().getSlot(), bagItem.getSlot());
return true;
} catch (NetworkException ex) {
LOG.log(Level.SEVERE, " Failed to de-equip.", ex);
} finally {
screen.updateZOrder(LUtil.getRootElement(this));
}
}
return false;
}
示例3: actionPerformed
import com.jme3.input.event.MouseButtonEvent; //导入依赖的package包/类
@Override
public void actionPerformed(ActionData data) {
Screen screen = data.getApp().getScreen();
ZMenu subMenu = new ZMenu(screen) {
};
CheckBox snapToFloor = new CheckBox(screen) {
@Override
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
Config.get().putBoolean(Config.BUILD_SNAP_TO_FLOOR, toggled);
}
};
snapToFloor.setIsCheckedNoCallback(Config.get().getBoolean(Config.BUILD_SNAP_TO_FLOOR, Config.BUILD_SNAP_TO_FLOOR_DEFAULT));
subMenu.addMenuItem("Snap to floor", snapToFloor, null);
addCategory(subMenu, screen, "Location Grid Snap", Config.BUILD_LOCATION_SNAP, Config.BUILD_LOCATION_SNAP_DEFAULT);
addCategory(subMenu, screen, "Rotation Grid Snap", Config.BUILD_EULER_ROTATION_SNAP,
Config.BUILD_EULER_ROTATION_SNAP_DEFAULT);
addCategory(subMenu, screen, "Scale Grid Snap", Config.BUILD_SCALE_SNAP, Config.BUILD_SCALE_SNAP_DEFAULT);
screen.addElement(subMenu);
subMenu.showMenu(null, data.getX(), data.getY() - subMenu.getHeight());
}
示例4: armourGroup
import com.jme3.input.event.MouseButtonEvent; //导入依赖的package包/类
private Container armourGroup(final int index, final Form form, List<Item> items, final Slot slot) {
Container heads = new Container(screen);
heads.setLayoutManager(new MigLayout(screen, "", "push[][][][][]push"));
for (final Item item : items) {
if (item != null) {
UIButton button = new UIButton(screen) {
@Override
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
start.getInitialEquipment().set(index, item);
start.getSpatial().setAppearance(slot, item.getAppearance());
start.getSpatial().reload();
}
};
button.setButtonIcon(32, 32, String.format("Icons/%s", item.getIcon1()));
button.setToolTipText(item.getDisplayName());
heads.addChild(button, "width 38, height 38");
form.addFormElement(button);
}
}
return heads;
}
示例5: BuildToolArea
import com.jme3.input.event.MouseButtonEvent; //导入依赖的package包/类
public BuildToolArea(ToolManager toolMgr, final ElementManager screen) {
super(GameHudType.BUILD, toolMgr, screen, "BuildToolBar", "Buildbar", 7);
//
updateBarText();
Container el = new Container(screen, UIDUtil.getUID(), mainToolBarStyle.getVector2f("propSearchPosition"),
mainToolBarStyle.getVector2f("propSearchSize"), Vector4f.ZERO, null);
el.setLayoutManager(new MigLayout(screen, "", "[][fill, grow][]", "[]"));
propSearch = new AutocompleteTextField<String>(screen, this);
propSearch.setToolTipText("Type in a partial or full prop name and press Ctrl+Space to list all props matching that name");
el.addChild(new Label("Prop: ", screen));
el.addChild(propSearch, "ay 50%");
FancyButton add = new FancyButton(screen) {
@Override
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
BuildAppState bas = screen.getApplication().getStateManager().getState(BuildAppState.class);
bas.add(propSearch.getText());
}
};
add.setText("Add");
el.addChild(add);
container.addChild(el);
}
示例6: forwardEvents
import com.jme3.input.event.MouseButtonEvent; //导入依赖的package包/类
public void forwardEvents(NiftyInputConsumer nic) {
int queueSize = inputQueue.size();
for (int i = 0; i < queueSize; i++){
InputEvent evt = inputQueue.get(i);
if (evt instanceof MouseMotionEvent){
onMouseMotionEventQueued( (MouseMotionEvent)evt, nic);
}else if (evt instanceof MouseButtonEvent){
onMouseButtonEventQueued( (MouseButtonEvent)evt, nic);
}else if (evt instanceof KeyInputEvent){
onKeyEventQueued( (KeyInputEvent)evt, nic);
}
}
inputQueue.clear();
}
示例7: s3dOnTouchDownEvent
import com.jme3.input.event.MouseButtonEvent; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void s3dOnTouchDownEvent(TouchEvent evt) {
float x = ToolKit.isAndroid() ? touchXY.x : mouseXY.x;
float y = ToolKit.isAndroid() ? touchXY.y : mouseXY.y;
Node target = getEventNode(x, y);
if (target != null) {
MouseUIButtonEvent<NodeEventTarget> mevt = new MouseUIButtonEvent<NodeEventTarget>(
new MouseButtonEvent(0, true, (int) x, (int) y), new NodeEventTarget(this, target),
keyboardModifiers);
if (target instanceof MouseButtonListener) {
((MouseButtonListener<NodeEventTarget>) target).onMouseButton(mevt);
}
if (target instanceof TouchListener) {
((TouchListener) target).onTouchDown(evt);
}
eventNodes.put(evt.getPointerId(), target);
}
}
示例8: onMouseButtonEvent
import com.jme3.input.event.MouseButtonEvent; //导入依赖的package包/类
@Override
public void onMouseButtonEvent(MouseButtonEvent evt) {
if (evt.getButtonIndex() == 0) {
BaseElement mouseFocusElement = screen.getMouseFocusElement();
if (mouseFocusElement != null) {
elementTree.setSelectedRowObjects(Arrays.asList(mouseFocusElement));
highlightSelection();
for (TableRow r : elementTree.getSelectedRows()) {
elementTree.scrollToRow(r.getRowIndex());
break;
}
}
}
endPick();
evt.setConsumed();
}
示例9: convertMouseButtonEvent
import com.jme3.input.event.MouseButtonEvent; //导入依赖的package包/类
private void convertMouseButtonEvent(MouseEvent me, boolean isPressed) {
int button = MouseInput.BUTTON_LEFT;
switch (me.getButton()) {
case NONE:
return;
case MIDDLE:
button = MouseInput.BUTTON_MIDDLE;
break;
case PRIMARY:
button = MouseInput.BUTTON_LEFT;
break;
case SECONDARY:
button = MouseInput.BUTTON_RIGHT;
}
MouseButtonEvent mbe = new MouseButtonEvent(button, isPressed, (int)me.getX(), (int)me.getY());
synchronized (eventQueue) {
eventQueue.add(mbe);
}
}
示例10: onMouseButtonEvent
import com.jme3.input.event.MouseButtonEvent; //导入依赖的package包/类
@Override
public void onMouseButtonEvent( MouseButtonEvent evt ) {
if( !isEnabled() ) {
return;
}
if( evt.isPressed() ) {
// Save the location for later
clickStart.set(evt.getX(), evt.getY());
} else if( evt.isReleased() ) {
Vector2f click = new Vector2f(evt.getX(), evt.getY());
if( click.distanceSquared(clickStart) < clickRadiusSq ) {
processClickEvent(click, evt);
}
}
}
示例11: onMouseLeftReleased
import com.jme3.input.event.MouseButtonEvent; //导入依赖的package包/类
@Override
public void onMouseLeftReleased(MouseButtonEvent evt) {
if (isEnabled) {
if (isPressed) {
isPressed = false;
if (doubleClick) {
selectTextRangeDoubleClick();
doubleClick = false;
} else if (tripleClick) {
selectTextRangeTripleClick();
tripleClick = false;
} else {
setCaretPositionByXNoRange(evt.getX());
if (caretIndex >= 0)
this.setTextRangeEnd(caretIndex);
else
this.setTextRangeEnd(0);
}
}
}
}
示例12: DialogBox
import com.jme3.input.event.MouseButtonEvent; //导入依赖的package包/类
/**
* Creates a new instance of the Dialog control
*
* @param screen The screen control the Element is to be added to
* @param UID A unique String identifier for the Element
* @param position A Vector2f containing the x/y position of the Element
* @param dimensions A Vector2f containing the width/height dimensions of the Element
* @param resizeBorders A Vector4f containg the border information used when resizing the default image (x = N, y = W, z = E, w = S)
* @param defaultImg The default image to use for the DialogBox window
*/
public DialogBox(ElementManager screen, String UID, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg) {
super(screen, UID, position, dimensions, resizeBorders, defaultImg);
Vector4f indents = screen.getStyle("Window").getVector4f("contentIndents");
btnCancel = new ButtonAdapter(screen, UID + ":btnCancel",
new Vector2f(
indents.y,
contentArea.getHeight()-screen.getStyle("Button").getVector2f("defaultSize").y-indents.w
)
) {
@Override
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
onButtonCancelPressed(evt, toggled);
}
};
btnCancel.setText("Cancel");
btnCancel.setDocking(Docking.SW);
addWindowContent(btnCancel);
form.addFormElement(btnCancel);
}
示例13: setIsToggled
import com.jme3.input.event.MouseButtonEvent; //导入依赖的package包/类
/**
* Set a toggle button state to toggled/untoggled and calls the user left mouse button event methods
* @param isToggled boolean
*/
public void setIsToggled(boolean isToggled) {
this.isToggled = isToggled;
if (pressedImg != null && isToggled) {
runPressedEffect(false);
} else {
runResetEffect();
}
MouseButtonEvent evtd = new MouseButtonEvent(0,true,0,0);
MouseButtonEvent evtu = new MouseButtonEvent(0,false,0,0);
onButtonMouseLeftDown(evtd, isToggled);
onButtonMouseLeftUp(evtu, isToggled);
if (radioButtonGroup != null) {
if (isToggled)
radioButtonGroup.setSelected(this);
}
evtu.setConsumed();
evtd.setConsumed();
}
示例14: onMouseLeftPressed
import com.jme3.input.event.MouseButtonEvent; //导入依赖的package包/类
@Override
public void onMouseLeftPressed(MouseButtonEvent evt) {
if (isEnabled) {
if (isToggleButton) {
if (isToggled) {
if (!isRadioButton) isToggled = false;
} else {
isToggled = true;
}
}
runPressedEffect(true);
isStillPressed = true;
initClickPause = true;
currentInitClickTrack = 0;
onButtonMouseLeftDown(evt, isToggled);
}
evt.setConsumed();
}
示例15: onMouseLeftReleased
import com.jme3.input.event.MouseButtonEvent; //导入依赖的package包/类
@Override
public void onMouseLeftReleased(MouseButtonEvent evt) {
if (isEnabled) {
if (!isToggleButton) {
if (getHasFocus()) {
runLoseFocusEffect();
runHoverEffect(false);
} else {
runLoseFocusEffect();
}
} else {
if (!isToggled) {
runLoseFocusEffect();
runHoverEffect(false);
}
}
isStillPressed = false;
initClickPause = false;
currentInitClickTrack = 0;
onButtonMouseLeftUp(evt, isToggled);
if (radioButtonGroup != null)
radioButtonGroup.setSelected(this);
}
evt.setConsumed();
}