我按下逃生时试图关闭灯箱,但弹出窗口没有关闭.
$(document).keypress(function(e){
if(e.keyCode==27 && popupStatus==1){
disablePopup();
}
});
Run Code Online (Sandbox Code Playgroud)
这是完整的代码:
var popupStatus = 0;
var buttonDivID = "";
var conDivID = "";
//determine which div is clicked
function setDiv( div ) {
if( div==1){
conDivID = "#intro";
}
if( div==2) {
conDivID = "#presentation";
}
}
//loading popup with jQuery magic!
function loadPopup(){
//loads popup only if it is disabled
if(popupStatus==0){
$("#backgroundPopup").css({
"opacity": "0.7"
});
$("#backgroundPopup").fadeIn("slow");
$(conDivID).fadeIn("slow");
$(conDivID).CenterIt();
popupStatus = 1;
}
}
//disabling popup with jQuery magic!
function disablePopup(){
//disables …
Run Code Online (Sandbox Code Playgroud) 我正在努力想出如何在我试图创建的DTO映射器中实现工厂模式.我很确定我需要重新考虑我的设计.这是我正在运行的一个非常小的例子:
public abstract class Person
{
public string Name { get; set; }
public decimal Salary { get; set; }
}
public class Employee : Person
{
public Employee()
{
this.Salary = 20000;
}
}
public class Pilot : Person
{
public string PilotNumber { get; set; }
public Pilot()
{
this.Salary = 50000;
}
}
public static class PersonFactory
{
public static Person CreatePerson(string typeOfPerson)
{
switch (typeOfPerson)
{
case "Employee":
return new Employee();
case "Pilot":
return new Pilot(); …
Run Code Online (Sandbox Code Playgroud) 我在Windows上使用阻塞C套接字.我使用它们将数据的更新从服务器发送到客户端,反之亦然.我以高频率(每100毫秒)发送更新.该send()
函数是否会recv()
在结束前等待收件人接收数据?
如果我理解man手册页,我会假设:
"send()的成功完成并不能保证传递信息."
那么,如果一个人运行10次,send()
而另一个只完成1次,会发生什么recv()
?
我是否需要使用某种确认系统?
我发现了很多关于使用GLUT检测是否Ctrl使用GLUT_ACTIVE_CTRL宏按下键的信息.该宏仅在键盘或鼠标回调函数中有效.我需要知道Ctrl在主循环中的某个点是否按下了键,但GLUT_ACTIVE_CTRL似乎在此上下文中不起作用.
那么,有没有办法以Ctrl平台独立的GLUT-ish方式检测密钥上的密钥和密钥事件(没有任何其他密钥被键入)?
编辑:Ctrl按下键时不会触发键盘回调(至少对于默认设置).这是基本问题,我只能在Ctrl按下另一个键时测试是否按下了键,从而触发键盘回调.
我的设置是这样的:
// ... in main function:
glutKeyboardFunc(keyboard);
//later in the code:
void keyboard(unsigned char key, int _x, int _y)
{
printf("keydown \n");
if (glutGetModifiers() == GLUT_ACTIVE_CTRL) {
printf("control key is pressed.\n");
}
//etc.
Run Code Online (Sandbox Code Playgroud)
当我按任何正常字符"keydown"打印到stdout.当我按下Ctrl键时,没有任何反应.如果我按Ctrl+ C,则按下"keydown控制键".打印出来.
但是,在我的主循环中,我添加了:
if (glutGetModifiers() == GLUT_ACTIVE_CTRL) {
printf("Control key down.\n");
} else {
printf("Control key up.\n");
}
Run Code Online (Sandbox Code Playgroud)
它总是打印"控制键".无论我是否Ctrl按键.
我有一个带按钮的表格.此应用程序旨在在触摸屏计算机上运行.单击按钮时,我想知道它是否被鼠标或触摸屏点击.
这可能吗?如果是这样,怎么样?
我有一个simple.jar文件,保留在c:/ JAR中.当我使用maven war插件创建war文件时,它会将所有依赖项复制到lib文件夹中.
我怎样才能让maven将simple.jar复制到lib文件夹中.
这是我正在尝试使用的正则表达式:
/^(\w|\.|-)+?@(\w|-)+?\.\w{2,4}($|\.\w{2,4})$/gim
Run Code Online (Sandbox Code Playgroud)
我在这个网站上找到了它,当我在那里试用它时效果很好.但是只要我把它放在我的代码中,我就会得到这样的信息:
Warning: preg_match() [function.preg-match]: Unknown modifier 'g' in C:\xampp\htdocs\swebook\includes\classes.php on line 22
Run Code Online (Sandbox Code Playgroud)
任何人都可以解释什么是错的,为什么它在该网站上工作而不是在我的代码中?
在CoreData表上执行此查询的最有效方法是什么?要使用标准员工数据库模型 - 我希望所有包含职位描述为"chef"的员工的部门都使用DISTINCT部门ID.实际上,这里只有一个表(Employees)相关 - 我实际上并没有一个department表,只是重复的部门ID.
我有一个textarea,如果输入的字符达到最大长度,我想阻止输入.
我目前有一个文本框的Jquery脚本,用于计算输入的字符,并希望添加一些内容,一旦输入150个字符,将阻止textarea中的输入.
我已经尝试将max-length插件与我的脚本结合使用,但它们似乎不起作用.感谢帮助.
当前代码
(function($) {
$.fn.charCount = function(options){
// default configuration properties
var defaults = {
allowed: 150,
warning: 25,
css: 'counter',
counterElement: 'span',
cssWarning: 'warning',
cssExceeded: 'exceeded',
counterText: '',
container: undefined // New option, accepts a selector string
};
var options = $.extend(defaults, options);
function calculate(obj,$cont) {
// $cont is the container, now passed in instead.
var count = $(obj).val().length;
var available = options.allowed - count;
if(available <= options.warning && available >= 0){
$cont.addClass(options.cssWarning);
} else {
$cont.removeClass(options.cssWarning); …
Run Code Online (Sandbox Code Playgroud) 我在Windows 7上使用Python 2.6
我从这里借了一些代码: Python,Unicode和Windows控制台
我的目标是能够在Windows控制台中显示uft-8字符串.
显然在python 2.6中
sys.setdefaultencoding函数()
不再受支持
但是,在我尝试使用它之前,我写了reload(sys),它神奇地没有错误.
此代码不会出错,但会显示有趣的字符而不是日文文本. 我相信问题是因为我没有成功更改Windows控制台的代码页.
这些是我的尝试,但它们不起作用:
reload(sys)
sys.setdefaultencoding('utf-8')
print os.popen('chcp 65001').read()
sys.stdout.encoding = 'cp65001'
Run Code Online (Sandbox Code Playgroud)
也许您可以使用win32console来更改代码页? 我尝试了我链接的网站上的代码,但它也从win32console中出错..也许该代码已经过时了.
这是我的代码,这不是错误,但打印有趣的字符:
#coding=<utf8>
import os
import sys
import codecs
reload(sys)
sys.setdefaultencoding('utf-8')
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
sys.stderr = codecs.getwriter('utf8')(sys.stderr)
#print os.popen('chcp 65001').read()
print(sys.stdout.encoding)
sys.stdout.encoding = 'cp65001'
print(sys.stdout.encoding)
x = raw_input('press enter to continue')
a = '???????'#.decode('utf8')
print a
x = raw_input()
Run Code Online (Sandbox Code Playgroud)