本文整理汇总了C++中KeyEvent::event方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyEvent::event方法的具体用法?C++ KeyEvent::event怎么用?C++ KeyEvent::event使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyEvent
的用法示例。
在下文中一共展示了KeyEvent::event方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyEvent
bool IPWidget::keyEvent(KeyEvent &ke)
{
// So we accept up/down when we are over a number field
//XXXX:NNN.NNN.NNN.NNN
// Is it even in our space
Dout(dc::trace,"IPWidget ::keyEvent at " << ke.x() << " " << ke.y());
if (!contains(ke.x(),ke.y())) return false;
setFocusWidget(true);
int ev=ke.event();
if ((ev & KeyEvent::KeyRelease))
{
if ((ev & KeyEvent::KeyUp) || (ev & KeyEvent::KeyDown))
{
int col=ke.x()-x();
int row=ke.y()-y();
if ((col != 3) && (col!= 7) && (col!= 11)) // tweak a digit
{
int sgn=-1;
if (ev & KeyEvent::KeyUp) sgn=1;
int pos = col;
if (ipv==IPV6 && row ==1)
pos += 16;
int pwr = 2 - (pos % 4);
int incr = sgn;
for (int i=0; i<pwr; i++)
incr*=10;
std::string quad=ip.substr((pos/4)*4,3);
std::istringstream iss(quad);
int iquad;
iss>>iquad;
fprintf(stderr,"%i %s %i\n",incr,quad.c_str(),iquad);
iquad += incr;
// Range is 0..255 for a quad
// What we do is first get the current quad value, the amount we are
// incrementing by and cycle through, clamping to valid values
if (iquad <0 || iquad> 255) iquad-=incr;
std::ostringstream oss;
oss << std::setfill('0') << std::setw(3) << iquad;
ip.replace((pos/4)*4,3,oss.str());
fprintf(stderr,"%i %s %s\n",iquad,oss.str().c_str(),ip.c_str());
setDirty(true);
return true;
}
}