在这篇文章中,我们将带领您了解可可–绑定自定义NSView:是否要求创建一个IBPlugin?的全貌,包括可可授权怎么用的相关情况。同时,我们还将为您介绍有关645webpack常用plugins:c
在这篇文章中,我们将带领您了解可可 – 绑定自定义NSView:是否要求创建一个IBPlugin?的全貌,包括可可授权怎么用的相关情况。同时,我们还将为您介绍有关645 webpack常用plugins:clean-webpack-plugin,html-webpack-plugin,webpack.DefinePlugin,copy-webpack-plug、apkplug利用plugin.xml传递自定义属性、ckan.plugins.core.PluginNotFoundException:pdf_view错误、cocoa – NSMenuItem中的自定义NSView未接收鼠标事件的知识,以帮助您更好地理解这个主题。
本文目录一览:- 可可 – 绑定自定义NSView:是否要求创建一个IBPlugin?(可可授权怎么用)
- 645 webpack常用plugins:clean-webpack-plugin,html-webpack-plugin,webpack.DefinePlugin,copy-webpack-plug
- apkplug利用plugin.xml传递自定义属性
- ckan.plugins.core.PluginNotFoundException:pdf_view错误
- cocoa – NSMenuItem中的自定义NSView未接收鼠标事件
可可 – 绑定自定义NSView:是否要求创建一个IBPlugin?(可可授权怎么用)
@interface CePatternView : NSView { NSImage* image; id observableObjectForImage; Nsstring* keyPathForImage; } @end
我实现了以下内容来公开绑定:
+ (void)initialize { // Expose the "image" binding to IB. [self exposeBinding:@"image"]; } - (Class)valueClassForBinding:(Nsstring *)binding { if([binding isEqualToString:@"image"]) return [NSImage class]; return nil; // UnkNown binding }
不幸的是,图像绑定不会显示在Interface Builder中.
我真的需要创建一个IBPlugin来在Interface Builder中公开绑定吗?对于我不打算重用的自定义视图,这似乎是过分的.
解决方法
对问题主体的回答:是的,您需要一个IB插件才能在IB中公开绑定.
您的代码不会在Interface Builder中运行,除非将其放入Interface Builder,并且将显示Binding:消息是您的代码.因此,您需要将其放入Interface Builder.这意味着要写一个IB插件.
此外,IB插件与旧的IB调色板不同.插件需要IB 3,并且容易创建.调色板需要IB 2,并且痛苦地创建.
645 webpack常用plugins:clean-webpack-plugin,html-webpack-plugin,webpack.DefinePlugin,copy-webpack-plug
-
- 前端小菜鸟,喜欢前端,不断学习
- 微信:jie178463596
- 微信小群:纯粹讨论技术、面试、工作为主,划水少,拒绝广告
认识Plugin
CleanWebpackPlugin
HtmlWebpackPlugin
生成的index.html分析
自定义HTML模板
自定义模板数据填充
DefinePlugin的介绍
DefinePlugin的使用
copyWebpackPlugin
目录结构
wk.config.js
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { DefinePlugin } = require('webpack'); // DefinePlugin是webpack内置插件
const copyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: "./src/main.js",
output: {
filename: "js/bundle.js",
// 必须是一个绝对路径
path: path.resolve(__dirname, "./build"),
// assetmodulefilename: "img/[name].[hash:6][ext]"
},
module: {
rules: [
{
// 规则使用正则表达式
test: /\.css$/, // 匹配资源
use: [
// { loader: "css-loader" },
// 注意: 编写顺序(从下往上, 从右往做, 从后往前)
"style-loader",
{
loader: "css-loader",
options: {
importLoaders: 1
}
},
"postcss-loader"
],
// loader: "css-loader"
},
{
test: /\.less$/,
use: [
"style-loader",
{
loader: "css-loader",
options: {
importLoaders: 2
}
},
"postcss-loader",
"less-loader"
]
},
{
test: /\.(png|jpe?g|gif|svg)$/,
// type: "asset/resource", file-loader的效果
// type: "asset/inline", url-loader
type: "asset",
generator: {
filename: "img/[name].[hash:6][ext]"
},
parser: {
dataUrlCondition: {
maxSize: 100 * 1024
}
}
},
{
test: /\.ttf|eot|woff2?$/i,
type: "asset/resource",
generator: {
filename: "font/[name].[hash:6][ext]"
}
}
]
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
title: "哈哈 webpack",
template: "./public/index.html"
}),
new DefinePlugin({
// 要包裹两层引号
BASE_URL: '"./"'
}),
new copyWebpackPlugin({
patterns: [
{
// to: xxx, // 不用写,默认会使用output.path
from: "public",
globOptions: {
ignore: [
"**/index.html",
"**/.DS_Store",
"**/abc.txt"
]
}
}
]
})
]
}
publuc/index.html
<!DOCTYPE html>
<html lang="">
<head>
<Meta charset="utf-8">
<Meta http-equiv="X-UA-Compatible" content="IE=edge">
<Meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
build/index.html
<!DOCTYPE html>
<html lang="">
<head>
<Meta charset="utf-8">
<Meta http-equiv="X-UA-Compatible" content="IE=edge">
<Meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="./favicon.ico">
<title>杰帅的webpack</title>
<script defer src="js/bundle.js"></script></head>
<body>
<noscript>
<strong>We're sorry but 杰帅的webpack doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
apkplug利用plugin.xml传递自定义属性
plugin.xml文件除了定义插件属性外,开发者也可以根据自己需求添加自定义的属性。
demo源码下载地址 http://git.oschina.net/plug/apkplugBundles/tree/master/PluginDemo
1.配置代码如下
<?xml version="1.0" encoding="UTF-8"?> <plugin-features Bundle-Name="plugin文件传参" Bundle-SymbolicName="com.apkplug.plugindemo" Bundle-Version="1.0.3" date="2012.11.28" Install="false" provider-name="插件开发商的名称" provider-url="" Bundle-Activator="com.apkplug.plugindemo.SimpleBundle" Bundle-Activity="com.apkplug.plugindemo.MainActivity" mykey="我是插件自定义的一个参数" > </plugin-features>
2.定义com.apkplug.plugindemo.BundleContextFactory 用来保存插件启动时的上下文BundleContext
3.编写 com.apkplug.plugindemo.SimpleBundle implements BundleActivator
public class SimpleBundle implements BundleActivator { public void start(BundleContext context) throws Exception { System.out.println("Simple Bundle " + context.getBundle().getBundleId() + " has started."); //保存插件上下文BundleContext 在Activity中使用 BundleContextFactory.getInstance().setBundleContext(context); } public void stop(BundleContext context) { System.out.println("Simple Bundle " + context.getBundle().getBundleId() + " has stopped."); } }
4.在com.apkplug.plugindemo.MainActivity中获取mykey
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView info=(TextView) this.findViewById(R.id.info); info.setText("plugin.xml自定义key:"+ BundleContextFactory.getInstance().getBundleContext(). getBundle().getHeaders().get("mykey")); } }
ckan.plugins.core.PluginNotFoundException:pdf_view错误
我找到了解决方案。当我进入虚拟环境时,我运行带路径的pip命令。首先,我在虚拟环境中找到了pip命令所使用的路径,然后运行带有path的pip命令。
cocoa – NSMenuItem中的自定义NSView未接收鼠标事件
不幸的是,我最近决定尝试使用NSMenuItem的setView:方法来提供更好/更滑动的界面.基本上,我刚停止设置标题,创建了NSMenuItem,然后使用setView:来显示自定义视图.这非常有效,菜单项看起来很棒,我的自定义视图也会显示出来.
但是,当用户选择菜单项并释放鼠标时,该操作不再起作用(即,不调用openLink:).如果我只是简单地注释掉setView:call,那么动作再次起作用(当然,菜单项是空白的,但动作正确执行).那么,我的第一个问题是为什么设置视图会破坏NSMenuItem的操作.
没问题,我想,我会通过在我的自定义视图中检测mouseUp事件并从那里调用我的action方法来解决它.我将此方法添加到自定义视图中:
- (void)mouseUp:(NSEvent *)theEvent { NSLog(@"in mouseUp"); }
没有骰子!永远不会调用此方法.
我可以设置跟踪rects并接收mouseEntered:事件.我在mouseEntered例程中进行了一些测试,如下所示:
if ([[self window] ignoresMouseEvents]) { NSLog(@"ignoring mouse events"); } else { NSLog(@"not ignoring mouse events"); } if ([[self window] canBecomeKeyWindow]) { dNSLog((@"canBecomeKeyWindow")); } else { NSLog(@"not canBecomeKeyWindow"); } if ([[self window] isKeyWindow]) { dNSLog((@"isKeyWindow")); } else { NSLog(@"not isKeyWindow"); }
并得到以下回应:
not ignoring mouse events canBecomeKeyWindow not isKeyWindow
这是问题吗? “not isKeyWindow”?据推测,这并不好,因为Apple的文档说“如果用户点击不在关键窗口中的视图,默认情况下窗口会被提前并变为密钥,但不会调度鼠标事件.”但必须有办法检测这些事件.怎么样?
添加:
[[self window] makeKeyWindow];
尽管canBecomeKeyWindow是YES,但没有效果.
解决方法
- (void)mouseUp:(NSEvent*) event { NSMenuItem* mitem = [self enclosingMenuItem]; NSMenu* m = [mitem menu]; [m cancelTracking]; [m performActionForItemAtIndex: [m indexOfItem: mitem]]; }
但是我遇到了关键操作的问题,如果你解决了这个问题,也许你可以回答我的问题并帮助我一点点.
今天关于可可 – 绑定自定义NSView:是否要求创建一个IBPlugin?和可可授权怎么用的讲解已经结束,谢谢您的阅读,如果想了解更多关于645 webpack常用plugins:clean-webpack-plugin,html-webpack-plugin,webpack.DefinePlugin,copy-webpack-plug、apkplug利用plugin.xml传递自定义属性、ckan.plugins.core.PluginNotFoundException:pdf_view错误、cocoa – NSMenuItem中的自定义NSView未接收鼠标事件的相关知识,请在本站搜索。
本文标签: