public MainPage()
{
InitializeComponent();
ApplicationBar = new ApplicationBar();
ApplicationBar.Opacity = 1.0;
ApplicationBar.IsVisible = true;
ApplicationBar.IsMenuEnabled = true;
ApplicationBar.BackgroundColor = System.Windows.Media.Colors.Transparent;
ApplicationBarIconButton add = new ApplicationBarIconButton();
add.IconUri = new Uri("Icons/appbar.add.rest.png", UriKind.Relative);
add.Text = "add a friend";
ApplicationBar.Buttons.Add(add);
add.Click += new EventHandler(add_Click); //ERROR
ApplicationBarIconButton list = new ApplicationBarIconButton();
list.IconUri = new Uri("icons/appbar.folder.rest.png",UriKind.Relative);
list.Text = "List";
ApplicationBar.Buttons.Add(list);
ApplicationBarIconButton about = new ApplicationBarIconButton();
about.IconUri = new Uri("icons/appbar.questionmark.rest.png",UriKind.Relative);
about.Text = "about";
ApplicationBar.Buttons.Add(about);
Run Code Online (Sandbox Code Playgroud)
}
我在select元素中选择一个选项时调用javascript函数,如下所示:
<select id="select-thingy" onchange="foo(event, this); false;">
<option value="bar">asdf</option>
...
</select>
Run Code Online (Sandbox Code Playgroud)
该函数执行以下操作:
function foo(e, elem) {
var thingummy = elem.options[elem.selectedIndex].value;
alert(e.ctrlKey); // for testing only
if (e.ctrlKey) {
// do something
} else {
// do something else
}
}
Run Code Online (Sandbox Code Playgroud)
根据警报,e.ctrlKey未定义 - 我认为这应该返回true或false?我在这里错过了什么?
谢谢大家!
除非用户将鼠标移到地图上,否则我试图让谷歌地图连续平滑过度.使用'idle'事件处理程序会导致波动的平移动画.使用其他事件不会给我结果.我的initPan()函数的递归只会导致页面崩溃.这里 '空闲'连续平移方法的示例.
function initialize() {
var myOptions = {
zoom: 5,
center: markers.sanjose,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map_canvas'),
myOptions);
google.maps.event.addListener(map, 'idle', function() {
initPan(map);
});
google.maps.event.addListener(map, 'mouseout', function() {
stopPan(map);
});
}
function initPan(map) {
map.panBy(5, 0);
}
function stopPan(){
}
Run Code Online (Sandbox Code Playgroud) 我有一个喜欢的div:
<div id="specific">
<table cellpadding="2" border="0">
<tr><td>Choose category</td><td><select id="list_categories" runat="server"></select></td><td><asp:RequiredFieldValidator ControlToValidate="list_categories" runat="server" Display="Static" ErrorMessage="Select category" ID="verify_category"></asp:RequiredFieldValidator></td></tr>
<tr><td>Link name : </td><td><asp:TextBox ID="link_name" runat="server"></asp:TextBox></td><td><asp:RequiredFieldValidator ControlToValidate="link_name" runat="server" Display="Static" ErrorMessage="Provide a name for link" ID="verify_link_name"></asp:RequiredFieldValidator></td></tr>
<tr><td>Link url : </td><td><asp:TextBox ID="link_url" runat="server"></asp:TextBox></td><td><asp:RegularExpressionValidator ID="verify_url" runat="server" ControlToValidate="link_url" Display="Static" ErrorMessage="Invalid link. Must be as http://www.stabiplan.com" ValidationExpression="^http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?$"></asp:RegularExpressionValidator></td></tr>
<tr><td>Link description</td><td><asp:TextBox ID="link_descr" runat="server"></asp:TextBox></td><td><asp:RequiredFieldValidator ControlToValidate="link_descr" runat="server" ID="verify_descr" Display="Static" ErrorMessage="Provide a link description"></asp:RequiredFieldValidator></td></tr>
<tr><td colspan="2"><center><asp:Button runat="server" ID="add_link_process" Text="Add link" OnClick="add_link_function" /></center></td></tr>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
和CodeBehind.cs的功能
protected void add_link_function( object sender, EventArgs e ) { …Run Code Online (Sandbox Code Playgroud) C#事件处理(包括所有委托和类似事件)和通过双击设计器中的表单(在Visual Studio中)生成的事件有什么区别?
哪些事件是最耗费资源的事件?鼠标悬停是"最差"还是点击?浏览器上是否有任何事件被认为非常严厉?我主要关注IE7,因为我们看到了性能问题.我们尽可能使用事件委托.
或者,如何分析实际运行的事件以确定哪些事件对运行时的性能影响最大?
我对这些活动感兴趣,请不要告诉我,我需要去看看我的功能在这些活动中的作用.那里可能存在问题,但这不是我的问题.
我有一些JButton,我试图在for循环中添加他们的动作侦听器,但它给出了空指针异常,但是如果我逐个添加它们就不会出现问题.我想知道我的错误点是什么.谢谢.
JButton[ ] myButtonArray = { but1, but2, but3 };
ButtonHandler bh = new ButtonHandler();
for (JButton cur : myButtonArray) { // I tried standard for loop as well.
cur.addActionListener(bh);
}
Run Code Online (Sandbox Code Playgroud) 我有一个NSTableView我的默认行为有一些问题.
如果我keyDown:在类别中重写了方法,如下所示:
- (void) keyDown:(NSEvent *)event {
[super keyDown:event];
}
Run Code Online (Sandbox Code Playgroud)
我无法再使用键盘箭头键更改行选择.这是为什么?
cocoa objective-c event-handling nstableview objective-c-category
我有一个单独的类,比方说class2,带有字典.我希望用字符号填充字典.
public class Class2
{
public Class2()
{
public Dictionary<string, string> someDictionary = new Dictionary<string, string>();
//I DON"T KNOW HOW TO CREATE AN EVENTHANDLER HERE FOR THE DICTIONARY
//how do i create the eventhandler if someDictionary changes?
}
}
Run Code Online (Sandbox Code Playgroud)
让我们说在class1中,我有一个listview,我想填充字典值,但更改它们,因为class2中的字典更改.
public class Class1
{
public Class1()
{
Class2 class2 = new Class2();
class2.SomeDictionaryChanged += new EventHandler(someDictionary_SomeDictionaryChanged);
}
void someData_SomeDataChanged(object sender, EventArgs e)
{
listView1.Add(class2.someDictionary);
}
}
Run Code Online (Sandbox Code Playgroud)
如何在class2中为字典创建一个eventhandler,如何检查class1中的字典是否发生了变化?
所有这些都是PSEUDOCODE,它不会编译,我不知道怎么做,这就是我问的问题.
我希望我的类的父级首先处理事件,然后我想让子级处理事件.有没有办法明确地将事件搞砸了?我想做这样的事情:
...
this.addEventListener(MouseEvent.CLICK, characterClicked);
...
private function characterClicked(e:Event):void{
// pass event to parent to be handled first
...
}
Run Code Online (Sandbox Code Playgroud)
这是可能的,如果是这样的话怎么样?
event-handling ×10
c# ×4
javascript ×3
asp.net ×1
cocoa ×1
dictionary ×1
events ×1
google-maps ×1
html ×1
java ×1
nstableview ×1
objective-c ×1
swing ×1