mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
Fix: Multiple actionView items do not handle tap event correctly
Resolves #1878
This commit is contained in:
@ -267,15 +267,8 @@ export class ActionBar extends common.ActionBar {
|
|||||||
if (item.actionView && item.actionView.android) {
|
if (item.actionView && item.actionView.android) {
|
||||||
// With custom action view, the menuitem cannot be displayed in a popup menu.
|
// With custom action view, the menuitem cannot be displayed in a popup menu.
|
||||||
item.android.position = enums.AndroidActionItemPosition.actionBar;
|
item.android.position = enums.AndroidActionItemPosition.actionBar;
|
||||||
|
|
||||||
menuItem.setActionView(item.actionView.android);
|
menuItem.setActionView(item.actionView.android);
|
||||||
// Note: When using a custom action view the toolbar's MenuItemClickListener is not triggered!
|
ActionBar._setOnClickListener(item);
|
||||||
menuItem.getActionView().setOnClickListener(new android.view.View.OnClickListener({
|
|
||||||
onClick:
|
|
||||||
function () {
|
|
||||||
item._raiseTap();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
else if (item.android.systemIcon) {
|
else if (item.android.systemIcon) {
|
||||||
// Try to look in the system resources.
|
// Try to look in the system resources.
|
||||||
@ -299,6 +292,14 @@ export class ActionBar extends common.ActionBar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static _setOnClickListener(item: ActionItem): void {
|
||||||
|
item.actionView.android.setOnClickListener(new android.view.View.OnClickListener({
|
||||||
|
onClick: function (v: android.view.View) {
|
||||||
|
item._raiseTap();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
public _onTitlePropertyChanged() {
|
public _onTitlePropertyChanged() {
|
||||||
var topFrame = frame.topmost();
|
var topFrame = frame.topmost();
|
||||||
if (this._toolbar && topFrame && topFrame.currentPage === this.page) {
|
if (this._toolbar && topFrame && topFrame.currentPage === this.page) {
|
||||||
|
Reference in New Issue
Block a user