Open moebiussurfing opened 4 years ago
@roymacdonald that's a snippet of the code I am using. macOS (Xcode 10, AppCode, High Sierra) with main branch:
//ofApp
//--------------------------------------------------------------
void ofApp::keyPressed(int key)
{
//switch window mode
if (key == 'f')
{
if (ofGetWindowMode() == OF_WINDOW)//go full screen
{
ofSetFullscreen(true);
}
else if (ofGetWindowMode() == OF_FULLSCREEN)//go window mode
{
ofSetFullscreen(false);
////TODO: bug:
// gui stops receiving mouse fine (goes -20 y px)
// when fullScreen to window mode switched
// 1. this do not solves nothing:
// it's only repaired when clicking the window bar to maximize window on top
//ofSetWindowPosition(0, -20);
//fontAnimator.windowResized(ofGetWindowWidth(), ofGetWindowHeight());
}
}
}
//---
//myClass: ofxFontAnimator
EDIT:
//--------------------------------------------------------------
ofxFontAnimator::ofxFontAnimator()
{
addMouseListeners();
}
//--------------------------------------------------------------
void ofxFontAnimator::setup()
{
...
//ofxGui theme
ofxGuiSetFont("fonts/PragmataProR_0822.ttf", 8);
ofxGuiSetDefaultHeight(18);
ofxGuiSetFillColor(ofColor(48));
...
gui.setup();
...
}
//--------------------------------------------------------------
void ofxFontAnimator::addMouseListeners()
{
ofAddListener(ofEvents().mouseDragged, this, &ofxFontAnimator::mouseDragged);
ofAddListener(ofEvents().mousePressed, this, &ofxFontAnimator::mousePressed);
ofAddListener(ofEvents().mouseReleased, this, &ofxFontAnimator::mouseReleased);
}
//--------------------------------------------------------------
void ofxFontAnimator::removeMouseListeners()
{
ofRemoveListener(ofEvents().mouseDragged, this, &ofxFontAnimator::mouseDragged);
ofRemoveListener(ofEvents().mousePressed, this, &ofxFontAnimator::mousePressed);
ofRemoveListener(ofEvents().mouseReleased, this, &ofxFontAnimator::mouseReleased);
}
//--------------------------------------------------------------
void ofxFontAnimator::mousePressed(ofMouseEventArgs &eventArgs)
{
const int &x = eventArgs.x;
const int &y = eventArgs.y;
const int &button = eventArgs.button;
//ofLogNotice("ofxFontAnimator") << "mousePressed " << x << ", " << y << ", " << button;
}
//--------------------------------------------------------------
void ofxFontAnimator::windowResized(int w, int h)
{
// move the ofxPanel to fit inside window screen
gui.setPosition(w-300, h-100);
// 2. this do not repair the mouse neither:
//removeMouseListeners();
//addMouseListeners();
}
I noticed that when changing window mode WINDOW/FULL SCREEN with ofSetFullscreen(MODE), ofxGui does not receive the mouse coordinates fine when switching from full-screen to window mode. (Window goes like 20 pixels above the top border in the vertical y axis. The mouse pointer is like displaced vertically 20 pixels below. In full-screen mode, it works.)
I need to click the window top title bar to resize again and then the mouse interacts fine with ofxGui again.
I am using a dual monitor setup if this could mean something... also, the ofxPanels are into some classes, not in ofApp. And the screen mode switching is called into ofApp.
Not sure what you mean about 'change in the coordinate system', but drawing/ofTranslate push/pop looks fine...
This is how I have aligned my 2 monitors:
When mirroring both monitors the problem is solved! Mouse cliks goes fine to the gui:
So I tried to move up the 1st monitor but do not help. I put both monitors to horizontal and aligned at the same height but it fails to.
Hi. so, does that code fix this issue? when the ofxFontAnimator::windowResized
gets called does it fix this issue?
nope, I commented that on keyPressed method... the only way that it's solved is when clicking window top bar and maximize window 'by macOS', or when using both monitor screens in mirror mode. (not tested with only one monitor plugged...)
hey @roymacdonald , thanks your your attention, but nevermind, it's not important.
just two more cents just in case help:
when switching from full-screen:
to window mode:
the window is moved down 20px (?). Then when clicking the bar goes up to top border again, and gui starts working again
(sometimes window goes locked and must resize from the borders, bar drag do not move) (the top header of panels are at -20px up just to hide the header, because the method to hide do not looked nice)
Hi, I understand. I am not seeing this issue though.
do you see this issue with other stuff besides the gui? if you have something where you add points to a polyline or mesh at the mouse position and then switch modes.
yes, it happens to some custom buttons I have in the same class. I tried with one monitor plugged and It happens too.
to window mode:
the problems happen when window is displaced like this screenshot. And sometimes drawings are displaced 20px too. When window is auto placed to top border mouse seems to work fine.
I have another thing to test: I am using a system windows manager system (Moom), I'll try to disable this too... EDIT: I disabled Moom but do not help.
I see. It is odd though. I'll try to replicate it.
Hi @moebiussurfing I think this has to do with a change in the coordinate system rather than an mouse events problem. As for what you say, those 20 pixels on the y axis seem to be there to compensate the window's top bar. I am not sure if there is a specific window event for when it changes to/from fullscreen. Although I guess that the window size event will work. So, register to this event so when it triggers then you just flag for a re-render. I'll try out this and let you know.
Originally posted by @roymacdonald in https://github.com/openframeworks/openFrameworks/pull/6429#issuecomment-552587497