Hi, I'm using SFML2 (git commit 71469f18153d8a86611310684cdfdee380ad2495) and I'm having some problems with input.
I managed to draw in a Qt widget using the code from the
QSFMLCanvas tutorial for 1.6 (
.hpp,
.cpp) and it works fine, except that I'm not getting MouseButtonPressed/Released events with PollEvent. I am however getting all sorts of other events, like MouseMoved/Entered/Left and KeyPressed/Released. I'm guessing that for some reason Qt swallows the mouse button events, but I have no idea where to start looking for the cause.
Here's my code (with my own irrelevant bits commented out):
#include "graphics/QSFMLCanvas.hpp"
// #include "graphics/Board.hpp"
#include <Qt/qapplication.h>
#include <Qt/qframe.h>
// #include <memory>
#include <iostream>
struct HayagoCanvas : QSFMLCanvas {
HayagoCanvas(QWidget* parent, const QPoint& pos, const QSize& size, int gridSize)
: QSFMLCanvas(parent, pos, size)
, gridSize(gridSize)
// , board(NULL)
{
}
private:
int gridSize;
// std::unique_ptr<Board> board;
void OnInit() {
// board.reset(new Board(GetWidth(), GameState(gridSize)));
}
void OnUpdate() {
sf::Event event;
while(PollEvent(event)) {
std::cout << "Event polled: " << event.Type << std::endl;
// if(event.Type == sf::Event::MouseButtonReleased) {
// board->place(ConvertCoords(GetInput().GetMouseX(), GetInput().GetMouseY()));
// }
}
// board->drawBoard(*this);
// board->drawStones(*this);
}
};
int main(int argc, char** argv) {
QApplication app(argc, argv);
QFrame* frame = new QFrame;
frame->setWindowTitle("Hayago");
frame->resize(640, 640);
frame->show();
HayagoCanvas* canvas = new HayagoCanvas(frame, QPoint(20, 20), QSize(600, 600), 9);
canvas->show();
return app.exec();
}