Commit 254ae138 authored by moliata's avatar moliata Committed by Evan W. Patton

Added a click event to an image component

parent b9d82d88
......@@ -1076,6 +1076,11 @@ public final class YoungAndroidFormUpgrader {
// }
srcCompVersion = 3;
}
if (srcCompVersion < 4) {
// The Click event was added.
// No properties need to be modified to upgrade to version 4.
srcCompVersion = 4;
}
return srcCompVersion;
}
......
......@@ -1580,7 +1580,10 @@ Blockly.Versioning.AllUpgradeMaps =
2: "noUpgrade",
// Scaling property was added (but not in use yet)
3: "noUpgrade"
3: "noUpgrade",
// Click event was added
4: "noUpgrade"
}, // End Image upgraders
......
......@@ -874,7 +874,9 @@ public class YaVersion {
// - The RotationAngle property was added.
// For IMAGE_COMPONENT_VERSION 3:
// - Scaling Property added, but hidden for now
public static final int IMAGE_COMPONENT_VERSION = 3;
// For IMAGE_COMPONENT_VERSION 4:
// - The Click event was added.
public static final int IMAGE_COMPONENT_VERSION = 4;
// For IMAGEPICKER_COMPONENT_VERSION 2:
// - The Alignment property was renamed to TextAlignment.
......
......@@ -17,6 +17,7 @@ import com.google.appinventor.components.annotations.UsesPermissions;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.common.YaVersion;
import com.google.appinventor.components.runtime.EventDispatcher;
import com.google.appinventor.components.runtime.errors.IllegalArgumentError;
import com.google.appinventor.components.runtime.util.AnimationUtil;
import com.google.appinventor.components.runtime.util.ErrorMessages;
......@@ -28,6 +29,7 @@ import com.google.appinventor.components.runtime.util.ViewUtil;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import java.io.IOException;
......@@ -73,6 +75,13 @@ public final class Image extends AndroidViewComponent {
}
};
view.setFocusable(true);
view.setClickable(true);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Click();
}
});
// Adds the component to its designated container
container.$add(this);
......@@ -83,6 +92,11 @@ public final class Image extends AndroidViewComponent {
return view;
}
@SimpleEvent(description = "An event that occurs when an image is clicked.")
public void Click() {
EventDispatcher.dispatchEvent(this, "Click");
}
/**
* Returns the path of the image's picture.
*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment