You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/08/24 22:34:38 UTC
svn commit: r807367 - in /incubator/pivot/trunk/wtk:
src/org/apache/pivot/wtk/ src/org/apache/pivot/wtk/skin/
test/org/apache/pivot/wtk/test/
Author: gbrown
Date: Mon Aug 24 20:34:37 2009
New Revision: 807367
URL: http://svn.apache.org/viewvc?rev=807367&view=rev
Log:
Check for isEnabled() in Component rather than just looking at enabled member variable; automatically disable MenuBar.Item when no menu is specified.
Modified:
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Container.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuBar.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuBarItemSkin.java
incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/menu_bar_test.wtkx
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java?rev=807367&r1=807366&r2=807367&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java Mon Aug 24 20:34:37 2009
@@ -2466,7 +2466,7 @@
protected boolean mouseMove(int x, int y) {
boolean consumed = false;
- if (enabled) {
+ if (isEnabled()) {
consumed = componentMouseListeners.mouseMove(this, x, y);
}
@@ -2474,14 +2474,14 @@
}
protected void mouseOver() {
- if (enabled) {
+ if (isEnabled()) {
mouseOver = true;
componentMouseListeners.mouseOver(this);
}
}
protected void mouseOut() {
- if (enabled) {
+ if (isEnabled()) {
mouseOver = false;
componentMouseListeners.mouseOut(this);
}
@@ -2490,7 +2490,7 @@
protected boolean mouseDown(Mouse.Button button, int x, int y) {
boolean consumed = false;
- if (enabled) {
+ if (isEnabled()) {
consumed = componentMouseButtonListeners.mouseDown(this, button, x, y);
}
@@ -2500,7 +2500,7 @@
protected boolean mouseUp(Mouse.Button button, int x, int y) {
boolean consumed = false;
- if (enabled) {
+ if (isEnabled()) {
consumed = componentMouseButtonListeners.mouseUp(this, button, x, y);
}
@@ -2510,7 +2510,7 @@
protected boolean mouseClick(Mouse.Button button, int x, int y, int count) {
boolean consumed = false;
- if (enabled) {
+ if (isEnabled()) {
consumed = componentMouseButtonListeners.mouseClick(this, button, x, y, count);
}
@@ -2521,7 +2521,7 @@
int wheelRotation, int x, int y) {
boolean consumed = false;
- if (enabled) {
+ if (isEnabled()) {
consumed = componentMouseWheelListeners.mouseWheel(this, scrollType,
scrollAmount, wheelRotation, x, y);
}
@@ -2532,7 +2532,7 @@
protected boolean keyTyped(char character) {
boolean consumed = false;
- if (enabled) {
+ if (isEnabled()) {
consumed = componentKeyListeners.keyTyped(this, character);
if (!consumed && parent != null) {
@@ -2546,7 +2546,7 @@
protected boolean keyPressed(int keyCode, Keyboard.KeyLocation keyLocation) {
boolean consumed = false;
- if (enabled) {
+ if (isEnabled()) {
consumed = componentKeyListeners.keyPressed(this, keyCode, keyLocation);
if (!consumed && parent != null) {
@@ -2560,7 +2560,7 @@
protected boolean keyReleased(int keyCode, Keyboard.KeyLocation keyLocation) {
boolean consumed = false;
- if (enabled) {
+ if (isEnabled()) {
consumed = componentKeyListeners.keyReleased(this, keyCode, keyLocation);
if (!consumed && parent != null) {
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Container.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Container.java?rev=807367&r1=807366&r2=807367&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Container.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Container.java Mon Aug 24 20:34:37 2009
@@ -760,8 +760,8 @@
// Synthesize mouse click event
if (component != null
&& component == mouseDownComponent
- && mouseDownComponent.isEnabled()
- && mouseDownComponent.isVisible()) {
+ && component.isEnabled()
+ && component.isVisible()) {
mouseClickConsumed = component.mouseClick(button, x - component.getX(),
y - component.getY(), mouseClickCount);
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuBar.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuBar.java?rev=807367&r1=807366&r2=807367&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuBar.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/MenuBar.java Mon Aug 24 20:34:37 2009
@@ -102,6 +102,12 @@
throw new UnsupportedOperationException("Menu bar items are always toggle buttons.");
}
+ @Override
+ public boolean isEnabled() {
+ return (super.isEnabled()
+ && menu != null);
+ }
+
public ListenerList<ItemListener> getItemListeners() {
return itemListeners;
}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuBarItemSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuBarItemSkin.java?rev=807367&r1=807366&r2=807367&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuBarItemSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/MenuBarItemSkin.java Mon Aug 24 20:34:37 2009
@@ -194,11 +194,6 @@
MenuBar.Item menuBarItem = (MenuBar.Item)button;
if (menuBarItem.isSelected()) {
- Menu menu = menuBarItem.getMenu();
- if (menu == null) {
- throw new IllegalStateException("Menu is not defined for " + button + ".");
- }
-
Display display = menuBarItem.getDisplay();
Point menuBarItemLocation = menuBarItem.mapPointToAncestor(display, 0, getHeight());
Modified: incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/menu_bar_test.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/menu_bar_test.wtkx?rev=807367&r1=807366&r2=807367&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/menu_bar_test.wtkx (original)
+++ incubator/pivot/trunk/wtk/test/org/apache/pivot/wtk/test/menu_bar_test.wtkx Mon Aug 24 20:34:37 2009
@@ -151,6 +151,8 @@
</Menu>
</menu>
</MenuBar.Item>
+
+ <MenuBar.Item buttonData="Empty"/>
</items>
</MenuBar>
</menuBar>