summaryrefslogtreecommitdiffstats
path: root/src/VButton.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/VButton.cpp')
-rw-r--r--src/VButton.cpp75
1 files changed, 41 insertions, 34 deletions
diff --git a/src/VButton.cpp b/src/VButton.cpp
index b4870f1..cabedd1 100644
--- a/src/VButton.cpp
+++ b/src/VButton.cpp
@@ -23,33 +23,12 @@ VButton::~VButton()
void VButton::shiftPressed(bool press)
{
- if (press==true){
- TQString tu=l.upper();
- if (tu.compare(l)==0){
- //TQPushButton::setText(tu);
- TQPushButton::setText(u);
- }
- else{
- TQPushButton::setText(tu);
- }
+ if (press)
+ {
+ TQPushButton::setText(u);
}
- else{
- TQPushButton::setText(l);
- }
-}
-
-void VButton::capsPressed(bool press)
-{
- if (press==true){
- TQString tu=l.upper();
- if (tu.compare(l)==0){
- TQPushButton::setText(tu);
- }
- else{
- TQPushButton::setText(u);
- }
- }
- else{
+ else
+ {
TQPushButton::setText(l);
}
}
@@ -107,34 +86,62 @@ void VButton::res()
orig_size=geometry();
}
-void VButton::mousePressEvent(TQMouseEvent * e)
+void VButton::enterEvent(TQEvent *e)
+{
+ TQPushButton::enterEvent(e);
+ inside = true;
+}
+
+void VButton::leaveEvent(TQEvent *e)
+{
+ TQPushButton::leaveEvent(e);
+ inside = false;
+}
+
+void VButton::mousePressEvent(TQMouseEvent *e)
{
press=true;
TQPushButton::mousePressEvent(e);
- sendKey();
- startTimer(500);
+ if (!isToggleButton())
+ {
+ // non toggle buttons need to send the key here
+ sendKey();
+ startTimer(500);
+ }
}
-void VButton::mouseReleaseEvent(TQMouseEvent * e)
+void VButton::mouseReleaseEvent(TQMouseEvent *e)
{
press=false;
TQPushButton::mouseReleaseEvent(e);
- TQT_TQOBJECT(this)->killTimers();
+ if (hitButton(e->pos()) && isToggleButton())
+ {
+ // toggle buttons need to send the key here because the underlying pushbutton state
+ // is only updated on mouse release
+ sendKey();
+ }
+ killTimers();
inrpt=false;
}
void VButton::timerEvent(TQTimerEvent *)
{
- if (!press){
+ if (!press)
+ {
inrpt=false;
return;
}
- if (press && !inrpt) {
+ if (press && !inrpt)
+ {
inrpt=true;
startTimer(120);
return;
}
- sendKey();
+ if (inside)
+ {
+ // Send key only if the mouse is still inside the button rectangle
+ sendKey();
+ }
}
#include "VButton.moc"