dart-gde / chrome.dart

Provide Dart interop with chrome.* APIs for Chrome Packaged Apps
Other
125 stars 48 forks source link

Event listeners for context menus don't work. #274

Open ghost opened 6 years ago

ghost commented 6 years ago

Event listeners for context menus don't work. Contents of background.dart

import 'package:chrome/chrome_ext.dart' as chrome;
import 'dart:html' as html;

void _contextMenuListener(event) {
  html.window.alert(event.toString());
  return;
}

// for creating context menu options on screen
void _createContextMenu() {
  chrome.contextMenus.removeAll();
  var params = new chrome.ContextMenusCreateParams(
      type: chrome.ItemType.NORMAL, title: "test", id: "test");
  chrome.contextMenus.create(params);
  chrome.contextMenus.onClicked.listen(_contextMenuListener);
}

void main() {
  _createContextMenu();
}

version: "0.10.1" Dart SDK version: Dart VM version: 2.0.0-dev.69.0 (Tue Jul 17 14:57:16 2018 +0200) on "linux_x64"

ghost commented 6 years ago

Stacktrace:

background.html:1 Error in event handler for contextMenus.onClicked: NoSuchMethodError: method not found: 'call'
Receiver: Closure 'ChromeStreamController$noArgs_closure'
Arguments: [Instance of 'JsObject', Instance of 'JsObject']
    at Object.wrapException (chrome-extension://fkkpfbfmhabbooamoimppmcheadnogpf/dart_background/context_menu.dart.js:3035:17)
    at ChromeStreamController$noArgs_closure.noSuchMethod$1 (chrome-extension://fkkpfbfmhabbooamoimppmcheadnogpf/dart_background/context_menu.dart.js:6672:17)
    at Object.J.noSuchMethod$1$ (chrome-extension://fkkpfbfmhabbooamoimppmcheadnogpf/dart_background/context_menu.dart.js:7335:39)
    at Object.Primitives_functionNoSuchMethod (chrome-extension://fkkpfbfmhabbooamoimppmcheadnogpf/dart_background/context_menu.dart.js:2960:16)
    at Object.Primitives__genericApplyFunctionWithPositionalArguments (chrome-extension://fkkpfbfmhabbooamoimppmcheadnogpf/dart_background/context_menu.dart.js:2993:20)
    at Object.Primitives_applyFunctionWithPositionalArguments (chrome-extension://fkkpfbfmhabbooamoimppmcheadnogpf/dart_background/context_menu.dart.js:2984:16)
    at dart._callDartFunction (chrome-extension://fkkpfbfmhabbooamoimppmcheadnogpf/dart_background/context_menu.dart.js:6819:14)
    at chrome-extension://fkkpfbfmhabbooamoimppmcheadnogpf/dart_background/context_menu.dart.js:7021:20
Crazywater commented 5 years ago

It seems like this should be a twoArgs Stream instead of a noArgs Stream - it gets passed "info" and a tab:

https://developer.chrome.com/apps/contextMenus#event-onClicked