ios stuff
This commit is contained in:
parent
c0d8650da2
commit
ec2e6830aa
@ -17,6 +17,7 @@ namespace SE
|
|||||||
extern const std::string CONST_HOLD_SIGNAL_NAME;
|
extern const std::string CONST_HOLD_SIGNAL_NAME;
|
||||||
extern const std::string CONST_CLICK_SIGNAL_NAME;
|
extern const std::string CONST_CLICK_SIGNAL_NAME;
|
||||||
extern const std::string CONST_DRAG_SIGNAL_NAME;
|
extern const std::string CONST_DRAG_SIGNAL_NAME;
|
||||||
|
extern const std::string CONST_TAPDOWN_SIGNAL_NAME;
|
||||||
|
|
||||||
|
|
||||||
typedef boost::variant<cardinal, vec2> TSignalParam;
|
typedef boost::variant<cardinal, vec2> TSignalParam;
|
||||||
@ -42,6 +43,7 @@ struct TWidgetStruct
|
|||||||
{
|
{
|
||||||
SignalMap[CONST_HOLD_SIGNAL_NAME] = std::shared_ptr<boost::signal<void (TSignalParam)>>(new boost::signal<void (TSignalParam)>());
|
SignalMap[CONST_HOLD_SIGNAL_NAME] = std::shared_ptr<boost::signal<void (TSignalParam)>>(new boost::signal<void (TSignalParam)>());
|
||||||
SignalMap[CONST_CLICK_SIGNAL_NAME] = std::shared_ptr<boost::signal<void (TSignalParam)>>(new boost::signal<void (TSignalParam)>());
|
SignalMap[CONST_CLICK_SIGNAL_NAME] = std::shared_ptr<boost::signal<void (TSignalParam)>>(new boost::signal<void (TSignalParam)>());
|
||||||
|
SignalMap[CONST_TAPDOWN_SIGNAL_NAME] = std::shared_ptr<boost::signal<void (TSignalParam)>>(new boost::signal<void (TSignalParam)>());
|
||||||
SignalMap[CONST_DRAG_SIGNAL_NAME] = std::shared_ptr<boost::signal<void (TSignalParam)>>(new boost::signal<void (TSignalParam)>());
|
SignalMap[CONST_DRAG_SIGNAL_NAME] = std::shared_ptr<boost::signal<void (TSignalParam)>>(new boost::signal<void (TSignalParam)>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,8 +135,8 @@ protected:
|
|||||||
|
|
||||||
TWidgetArr::iterator FindWidgetInArr(const std::string& widgetName);
|
TWidgetArr::iterator FindWidgetInArr(const std::string& widgetName);
|
||||||
|
|
||||||
vec2 LastTapPos;
|
std::map<int, vec2> LastTapPos;
|
||||||
vec2 TotalShift;
|
std::map<int, vec2> TotalShift;
|
||||||
|
|
||||||
boost::mutex WidgetListMutex;
|
boost::mutex WidgetListMutex;
|
||||||
|
|
||||||
@ -165,13 +167,13 @@ public:
|
|||||||
|
|
||||||
void AddWidgetTransformTask(TWidgetTransformTask widgetTransformTask);
|
void AddWidgetTransformTask(TWidgetTransformTask widgetTransformTask);
|
||||||
|
|
||||||
void OnMouseDown(vec2 pos);
|
void OnMouseDown(vec2 pos, int touchNumber);
|
||||||
|
|
||||||
void OnMouseUp(vec2 pos);
|
void OnMouseUp(vec2 pos, int touchNumber);
|
||||||
|
|
||||||
void OnMouseUpAfterMove(vec2 pos);
|
void OnMouseUpAfterMove(vec2 pos, int touchNumber);
|
||||||
|
|
||||||
void OnMove(vec2 shift);
|
void OnMove(vec2 shift, int touchNumber);
|
||||||
|
|
||||||
void ShowKeyboard(const std::string text = "");
|
void ShowKeyboard(const std::string text = "");
|
||||||
void HideKeyboard();
|
void HideKeyboard();
|
||||||
@ -182,6 +184,7 @@ public:
|
|||||||
std::shared_ptr<boost::signal<void (TSignalParam)>> GetOnClickSignal(const std::string& widgetName);
|
std::shared_ptr<boost::signal<void (TSignalParam)>> GetOnClickSignal(const std::string& widgetName);
|
||||||
std::shared_ptr<boost::signal<void (TSignalParam)>> GetOnHoldSignal(const std::string& widgetName);
|
std::shared_ptr<boost::signal<void (TSignalParam)>> GetOnHoldSignal(const std::string& widgetName);
|
||||||
std::shared_ptr<boost::signal<void (TSignalParam)>> GetSignal(const std::string& signalName, const std::string& widgetName);
|
std::shared_ptr<boost::signal<void (TSignalParam)>> GetSignal(const std::string& signalName, const std::string& widgetName);
|
||||||
|
std::shared_ptr<boost::signal<void (TSignalParam)>> GetOnTapDownSignal(const std::string& widgetName);
|
||||||
|
|
||||||
//TFunctionBinderInterface implementation:
|
//TFunctionBinderInterface implementation:
|
||||||
void SQ_MoveWidget(const SQChar *widgetName, float x, float y);
|
void SQ_MoveWidget(const SQChar *widgetName, float x, float y);
|
||||||
|
@ -116,13 +116,13 @@ public:
|
|||||||
virtual void UpdateQuick() { }
|
virtual void UpdateQuick() { }
|
||||||
//To process input - this method is called more frequently than Update()
|
//To process input - this method is called more frequently than Update()
|
||||||
|
|
||||||
virtual void OuterOnTapDown(vec2 p);
|
virtual void OuterOnTapDown(vec2 p, int touchNumber);
|
||||||
|
|
||||||
virtual void OuterOnTapUp(vec2 p);
|
virtual void OuterOnTapUp(vec2 p, int touchNumber);
|
||||||
|
|
||||||
virtual void OuterOnTapUpAfterMove(vec2 p);
|
virtual void OuterOnTapUpAfterMove(vec2 p, int touchNumber);
|
||||||
|
|
||||||
virtual void OuterOnMove(vec2 shift);
|
virtual void OuterOnMove(vec2 shift, int touchNumber);
|
||||||
|
|
||||||
|
|
||||||
virtual void InnerInit() { }
|
virtual void InnerInit() { }
|
||||||
|
@ -15,11 +15,11 @@ namespace SE
|
|||||||
void AppDeinit();
|
void AppDeinit();
|
||||||
void AppUpdate(int dt);
|
void AppUpdate(int dt);
|
||||||
void AppDraw();
|
void AppDraw();
|
||||||
void AppOnTapDown(int posx, int posy);
|
void AppOnTapDown(int posx, int posy, int touchNumber);
|
||||||
void AppOnTapUp(int posx, int posy);
|
void AppOnTapUp(int posx, int posy, int touchNumber);
|
||||||
void AppOnScroll(int shiftx, int shifty);
|
void AppOnScroll(int shiftx, int shifty, int touchNumber);
|
||||||
void AppOnScale(float scale);
|
void AppOnScale(float scale);
|
||||||
void AppOnTapUpAfterMove(int posx, int posy);
|
void AppOnTapUpAfterMove(int posx, int posy, int touchNumber);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -11,9 +11,10 @@
|
|||||||
@interface GLKViewTemplate : GLKView
|
@interface GLKViewTemplate : GLKView
|
||||||
{
|
{
|
||||||
|
|
||||||
CGPoint touchBeganLocation;
|
//CGPoint touchBeganLocation[255];
|
||||||
|
|
||||||
|
//bool touchMoved[255];
|
||||||
|
|
||||||
bool touchMoved;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
|
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
|
||||||
|
@ -7,6 +7,7 @@ namespace SE
|
|||||||
const std::string CONST_HOLD_SIGNAL_NAME = "OnHold";
|
const std::string CONST_HOLD_SIGNAL_NAME = "OnHold";
|
||||||
const std::string CONST_CLICK_SIGNAL_NAME = "OnClick";
|
const std::string CONST_CLICK_SIGNAL_NAME = "OnClick";
|
||||||
const std::string CONST_DRAG_SIGNAL_NAME = "OnDrag";
|
const std::string CONST_DRAG_SIGNAL_NAME = "OnDrag";
|
||||||
|
const std::string CONST_TAPDOWN_SIGNAL_NAME = "OnTapDown";
|
||||||
|
|
||||||
|
|
||||||
boost::mutex KeyMutex;
|
boost::mutex KeyMutex;
|
||||||
@ -261,16 +262,20 @@ void TGUIManager::MoveWidgetGroup(const std::string& widgetGroupName, const std:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TGUIManager::OnMouseDown(vec2 pos)
|
void TGUIManager::OnMouseDown(vec2 pos, int touchNumber)
|
||||||
{
|
{
|
||||||
//Xperimental - need to call widget methods and signals NOT IN "FOR" LOOP
|
//Xperimental - need to call widget methods and signals NOT IN "FOR" LOOP
|
||||||
|
|
||||||
|
//*Console<<"OnMouseDown touchNumber == "+tostr(touchNumber)+"\n";
|
||||||
|
|
||||||
boost::lock_guard<boost::mutex> guard(WidgetListMutex);
|
boost::lock_guard<boost::mutex> guard(WidgetListMutex);
|
||||||
|
|
||||||
TWidgetArr::reverse_iterator i;
|
TWidgetArr::reverse_iterator i;
|
||||||
|
|
||||||
LastTapPos = pos;
|
LastTapPos[touchNumber] = pos;
|
||||||
TotalShift = vec2(0,0);
|
TotalShift[touchNumber] = vec2(0,0);
|
||||||
|
|
||||||
|
std::vector<std::shared_ptr<boost::signal<void (TSignalParam)>>> signalMap;
|
||||||
|
|
||||||
for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i)
|
for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i)
|
||||||
{
|
{
|
||||||
@ -280,19 +285,29 @@ void TGUIManager::OnMouseDown(vec2 pos)
|
|||||||
|
|
||||||
i->Widget->OnTapDown(pos);
|
i->Widget->OnTapDown(pos);
|
||||||
i->IsMouseDown = true;
|
i->IsMouseDown = true;
|
||||||
|
|
||||||
|
signalMap.push_back((i->SignalMap[CONST_TAPDOWN_SIGNAL_NAME]));
|
||||||
|
|
||||||
if (! isTransparentForInput)
|
if (! isTransparentForInput)
|
||||||
{
|
{
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Keep this outside since signal may affect WidgetArr
|
||||||
|
BOOST_FOREACH(auto signalPtr, signalMap)
|
||||||
|
{
|
||||||
|
(*signalPtr)(TSignalParam(pos));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TGUIManager::OnMouseUp(vec2 pos)
|
void TGUIManager::OnMouseUp(vec2 pos, int touchNumber)
|
||||||
{
|
{
|
||||||
//Xperimental - need to call widget methods and signals NOT IN "FOR" LOOP
|
//Xperimental - need to call widget methods and signals NOT IN "FOR" LOOP
|
||||||
|
|
||||||
|
//*Console<<"OnMouseUp touchNumber == "+tostr(touchNumber)+"\n";
|
||||||
|
|
||||||
boost::lock_guard<boost::mutex> guard(WidgetListMutex);
|
boost::lock_guard<boost::mutex> guard(WidgetListMutex);
|
||||||
|
|
||||||
@ -326,10 +341,12 @@ void TGUIManager::OnMouseUp(vec2 pos)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TGUIManager::OnMouseUpAfterMove(vec2 pos)
|
void TGUIManager::OnMouseUpAfterMove(vec2 pos, int touchNumber)
|
||||||
{
|
{
|
||||||
//Xperimental - need to call widget methods and signals NOT IN "FOR" LOOP
|
//Xperimental - need to call widget methods and signals NOT IN "FOR" LOOP
|
||||||
|
|
||||||
|
//*Console<<"OnMouseUpAfterMove touchNumber == "+tostr(touchNumber)+"\n";
|
||||||
|
|
||||||
boost::lock_guard<boost::mutex> guard(WidgetListMutex);
|
boost::lock_guard<boost::mutex> guard(WidgetListMutex);
|
||||||
|
|
||||||
TWidgetArr::reverse_iterator i;
|
TWidgetArr::reverse_iterator i;
|
||||||
@ -353,7 +370,7 @@ void TGUIManager::OnMouseUp(vec2 pos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i->Widget->CheckClick(LastTapPos) && !i->Widget->CheckClick(pos))
|
if (i->Widget->CheckClick(LastTapPos[touchNumber]) && !i->Widget->CheckClick(pos))
|
||||||
{
|
{
|
||||||
bool isTransparentForInput = i->Widget->IsTransparentForInput();
|
bool isTransparentForInput = i->Widget->IsTransparentForInput();
|
||||||
i->Widget->OnTapUpAfterMoveOut(pos);
|
i->Widget->OnTapUpAfterMoveOut(pos);
|
||||||
@ -379,17 +396,18 @@ void TGUIManager::OnMouseUp(vec2 pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TGUIManager::OnMove(vec2 shift)
|
void TGUIManager::OnMove(vec2 shift, int touchNumber)
|
||||||
{
|
{
|
||||||
//Xperimental - need to call widget methods and signals NOT IN "FOR" LOOP
|
//Xperimental - need to call widget methods and signals NOT IN "FOR" LOOP
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TWidgetArr::reverse_iterator i;
|
TWidgetArr::reverse_iterator i;
|
||||||
|
|
||||||
bool moveIsProcessed = false;
|
bool moveIsProcessed = false;
|
||||||
bool moveOutIsProcessed = false;
|
bool moveOutIsProcessed = false;
|
||||||
|
|
||||||
TotalShift += shift;
|
TotalShift[touchNumber] += shift;
|
||||||
|
|
||||||
//LastTapPos += shift;
|
//LastTapPos += shift;
|
||||||
|
|
||||||
@ -397,7 +415,7 @@ void TGUIManager::OnMove(vec2 shift)
|
|||||||
|
|
||||||
for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i)
|
for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i)
|
||||||
{
|
{
|
||||||
if (!moveIsProcessed && i->Widget->CheckClick(LastTapPos-TotalShift))
|
if (!moveIsProcessed && i->Widget->CheckClick(LastTapPos[touchNumber]-TotalShift[touchNumber]))
|
||||||
{
|
{
|
||||||
bool isTransparentForInput = i->Widget->IsTransparentForInput();
|
bool isTransparentForInput = i->Widget->IsTransparentForInput();
|
||||||
|
|
||||||
@ -421,7 +439,7 @@ void TGUIManager::OnMove(vec2 shift)
|
|||||||
|
|
||||||
for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i)
|
for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i)
|
||||||
{
|
{
|
||||||
if (!moveOutIsProcessed && i->Widget->CheckClick(LastTapPos) && !i->Widget->CheckClick(LastTapPos-TotalShift))
|
if (!moveOutIsProcessed && i->Widget->CheckClick(LastTapPos[touchNumber]) && !i->Widget->CheckClick(LastTapPos[touchNumber]-TotalShift[touchNumber]))
|
||||||
{
|
{
|
||||||
bool isTransparentForInput = i->Widget->IsTransparentForInput();
|
bool isTransparentForInput = i->Widget->IsTransparentForInput();
|
||||||
|
|
||||||
@ -494,6 +512,15 @@ std::shared_ptr<boost::signal<void (TSignalParam)>> TGUIManager::GetOnHoldSignal
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<boost::signal<void (TSignalParam)>> TGUIManager::GetOnTapDownSignal(const std::string& widgetName)
|
||||||
|
{
|
||||||
|
|
||||||
|
TWidgetArr::iterator i = FindWidgetInArr(widgetName);
|
||||||
|
|
||||||
|
return i->SignalMap[CONST_TAPDOWN_SIGNAL_NAME];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<boost::signal<void (TSignalParam)>> TGUIManager::GetSignal(const std::string& signalName, const std::string& widgetName)
|
std::shared_ptr<boost::signal<void (TSignalParam)>> TGUIManager::GetSignal(const std::string& signalName, const std::string& widgetName)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -119,27 +119,27 @@ void TApplicationAncestor::OuterUpdate(cardinal timer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TApplicationAncestor::OuterOnTapDown(vec2 p)
|
void TApplicationAncestor::OuterOnTapDown(vec2 p, int touchNumber)
|
||||||
{
|
{
|
||||||
ResourceManager->GUIManager.OnMouseDown(p);
|
ResourceManager->GUIManager.OnMouseDown(p, touchNumber);
|
||||||
InnerOnTapDown(p);
|
InnerOnTapDown(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TApplicationAncestor::OuterOnTapUp(vec2 p)
|
void TApplicationAncestor::OuterOnTapUp(vec2 p, int touchNumber)
|
||||||
{
|
{
|
||||||
ResourceManager->GUIManager.OnMouseUp(p);
|
ResourceManager->GUIManager.OnMouseUp(p, touchNumber);
|
||||||
InnerOnTapUp(p);
|
InnerOnTapUp(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TApplicationAncestor::OuterOnTapUpAfterMove(vec2 p)
|
void TApplicationAncestor::OuterOnTapUpAfterMove(vec2 p, int touchNumber)
|
||||||
{
|
{
|
||||||
ResourceManager->GUIManager.OnMouseUpAfterMove(p);
|
ResourceManager->GUIManager.OnMouseUpAfterMove(p, touchNumber);
|
||||||
InnerOnTapUpAfterMove(p);
|
InnerOnTapUpAfterMove(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TApplicationAncestor::OuterOnMove(vec2 shift)
|
void TApplicationAncestor::OuterOnMove(vec2 shift, int touchNumber)
|
||||||
{
|
{
|
||||||
ResourceManager->GUIManager.OnMove(shift);
|
ResourceManager->GUIManager.OnMove(shift, touchNumber);
|
||||||
InnerOnMove(shift);
|
InnerOnMove(shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,27 +73,27 @@ void DestroyEngine()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AppOnTapDown(int posx, int posy)
|
void AppOnTapDown(int posx, int posy, int touchNumber)
|
||||||
{
|
{
|
||||||
App->OuterOnTapDown(vec2(posx, posy));
|
App->OuterOnTapDown(vec2(posx, posy), touchNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AppOnTapUp(int posx, int posy)
|
void AppOnTapUp(int posx, int posy, int touchNumber)
|
||||||
{
|
{
|
||||||
App->OuterOnTapUp(vec2(posx, posy));
|
App->OuterOnTapUp(vec2(posx, posy), touchNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AppOnTapUpAfterMove(int posx, int posy)
|
void AppOnTapUpAfterMove(int posx, int posy, int touchNumber)
|
||||||
{
|
{
|
||||||
App->OuterOnTapUpAfterMove(vec2(posx, posy));
|
App->OuterOnTapUpAfterMove(vec2(posx, posy), touchNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AppOnScroll(int shiftx, int shifty)
|
void AppOnScroll(int shiftx, int shifty, int touchNumber)
|
||||||
{
|
{
|
||||||
App->OuterOnMove(vec2(shiftx, shifty));
|
App->OuterOnMove(vec2(shiftx, shifty), touchNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,17 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
struct TTouchHashData
|
||||||
|
{
|
||||||
|
CGPoint first;
|
||||||
|
bool second;
|
||||||
|
int number;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::map<UITouch*, TTouchHashData> touchHash;
|
||||||
|
|
||||||
namespace SE
|
namespace SE
|
||||||
{
|
{
|
||||||
void ShowKeyboard(std::string text);
|
void ShowKeyboard(std::string text);
|
||||||
@ -23,53 +34,116 @@ void ShowKeyboard(std::string text);
|
|||||||
self = [super initWithFrame:frame];
|
self = [super initWithFrame:frame];
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
touchMoved = false;
|
self.multipleTouchEnabled = YES;
|
||||||
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) AddTouchToHash:(UITouch*)touch
|
||||||
|
{
|
||||||
|
touchHash[touch].first = [touch locationInView:self];
|
||||||
|
touchHash[touch].second = false;
|
||||||
|
|
||||||
|
for (int n = 0; n < 255; n++)
|
||||||
|
{
|
||||||
|
bool nExists = false;
|
||||||
|
|
||||||
|
for (auto i = touchHash.begin(); i != touchHash.end(); ++i)
|
||||||
|
{
|
||||||
|
if (i->second.number == n)
|
||||||
|
{
|
||||||
|
nExists = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nExists == false)
|
||||||
|
{
|
||||||
|
touchHash[touch].number = n;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) RemoveTouchFromHash:(UITouch*)touch
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||||
{
|
{
|
||||||
|
|
||||||
CGPoint location = [[[touches allObjects] objectAtIndex:0] locationInView:self];
|
//NSLog(@"touchesBegan");
|
||||||
|
|
||||||
touchBeganLocation = location;
|
for (NSUInteger i = 0; i < [[touches allObjects] count]; i++)
|
||||||
|
{
|
||||||
touchMoved = false;
|
UITouch *aTouch = [[touches allObjects] objectAtIndex:i];
|
||||||
|
|
||||||
SE::AppOnTapDown(location.x, self.bounds.size.height - location.y);
|
CGPoint location = [aTouch locationInView:self];
|
||||||
|
|
||||||
|
[self AddTouchToHash:aTouch];
|
||||||
|
|
||||||
|
SE::AppOnTapDown(location.x, self.bounds.size.height - location.y, touchHash[aTouch].number);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
||||||
{
|
{
|
||||||
CGPoint location = [[[touches allObjects] objectAtIndex:0] locationInView:self];
|
for (NSUInteger i = 0; i < [[touches allObjects] count]; i++)
|
||||||
|
|
||||||
CGPoint prevLocation = [[[touches allObjects] objectAtIndex:0] previousLocationInView:self];
|
|
||||||
|
|
||||||
if (abs(touchBeganLocation.x - location.x) > 10 || abs(touchBeganLocation.y - location.y) > 10)
|
|
||||||
{
|
{
|
||||||
touchMoved = true;
|
UITouch *aTouch = [[touches allObjects] objectAtIndex:i];
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
CGPoint location = [aTouch locationInView:self];
|
||||||
|
|
||||||
SE::AppOnScroll(prevLocation.x - location.x, -(prevLocation.y - location.y));
|
CGPoint prevLocation = [aTouch previousLocationInView:self];
|
||||||
|
|
||||||
|
if (abs(touchHash[aTouch].first.x - location.x) > 10 || abs(touchHash[aTouch].first.y - location.y) > 10)
|
||||||
|
{
|
||||||
|
touchHash[aTouch].second = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SE::AppOnScroll(prevLocation.x - location.x, -(prevLocation.y - location.y), touchHash[aTouch].number);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
||||||
{
|
{
|
||||||
CGPoint location = [[[touches allObjects] objectAtIndex:0] locationInView:self];
|
//NSLog(@"touchesEnded");
|
||||||
|
|
||||||
if (touchMoved)
|
for (NSUInteger i = 0; i < [[touches allObjects] count]; i++)
|
||||||
{
|
{
|
||||||
SE::AppOnTapUpAfterMove(location.x, self.bounds.size.height - location.y);
|
UITouch *aTouch = [[touches allObjects] objectAtIndex:i];
|
||||||
|
|
||||||
|
CGPoint location = [aTouch locationInView:self];
|
||||||
|
|
||||||
|
if (touchHash[aTouch].second)
|
||||||
|
{
|
||||||
|
SE::AppOnTapUpAfterMove(location.x, self.bounds.size.height - location.y, touchHash[aTouch].number);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SE::AppOnTapUp(location.x, self.bounds.size.height - location.y);
|
SE::AppOnTapUp(location.x, self.bounds.size.height - location.y, touchHash[aTouch].number);
|
||||||
|
}
|
||||||
|
touchHash.erase(aTouch);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
|
||||||
|
{
|
||||||
|
//NSLog(@"touchesCancelled");
|
||||||
|
|
||||||
|
|
||||||
|
for (NSUInteger i = 0; i < [[touches allObjects] count]; i++)
|
||||||
|
{
|
||||||
|
UITouch *aTouch = [[touches allObjects] objectAtIndex:i];
|
||||||
|
|
||||||
|
touchHash.erase(aTouch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -65,8 +65,13 @@ void SetKeyboardText(const char* newText);
|
|||||||
UIPinchGestureRecognizer *recognizer = [[UIPinchGestureRecognizer alloc]
|
UIPinchGestureRecognizer *recognizer = [[UIPinchGestureRecognizer alloc]
|
||||||
initWithTarget:self action:@selector(respondToPinch:)];
|
initWithTarget:self action:@selector(respondToPinch:)];
|
||||||
|
|
||||||
|
|
||||||
|
recognizer.delaysTouchesEnded = NO;
|
||||||
|
|
||||||
[self.view addGestureRecognizer:recognizer];
|
[self.view addGestureRecognizer:recognizer];
|
||||||
|
|
||||||
|
self.view.multipleTouchEnabled = YES;
|
||||||
|
|
||||||
//Keyboard
|
//Keyboard
|
||||||
|
|
||||||
_hiddenTextField = [[UITextField alloc] initWithFrame:CGRectMake(-200,-200,0,0)];
|
_hiddenTextField = [[UITextField alloc] initWithFrame:CGRectMake(-200,-200,0,0)];
|
||||||
|
Loading…
Reference in New Issue
Block a user