-
Notifications
You must be signed in to change notification settings - Fork 0
/
screenenduserinputeventhandler.h
57 lines (48 loc) · 1.67 KB
/
screenenduserinputeventhandler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// Created by phtran on 14/05/2016.
//
#ifndef FRONTEND_SCREENENDUSERINPUTEVENTHANDLER_H
#define FRONTEND_SCREENENDUSERINPUTEVENTHANDLER_H
#include "baseeventhandler.h"
#include "screen.h"
#include "screenfield.h"
#include "event.h"
#include "optionslist.h"
#include "editabandonsaveoptionslist.h"
#include "screenvalidationexception.h"
#include "container.h"
namespace UI
{
class ScreenEndUserInputEventHandler : public BaseEventHandler
{
UI::Screen& screen_;
public:
ScreenEndUserInputEventHandler(Screen& s) : screen_(s)
{ }
virtual void invoke()
{
if (screen_.focus() != screen_.end()) {
(*screen_.focus())->notifyEvent(LooseFocusEvent());
}
using OLPtr = std::shared_ptr<UI::OptionsList> ;
OLPtr h(OLPtr(new UI::EditAbandonSaveOptionsList(screen_)));
try {
screen_.validate();
} catch(const ::ValidationException& e) {
static const std::string prefix( "Error: " );
h = OLPtr(new UI::EditAbandonOptionsList(prefix + e.what(), screen_));
} catch (const Screen::ValidationException& e) {
static const std::string prefix( "Error: " );
h = OLPtr(new UI::EditAbandonOptionsList(prefix + e.what(), screen_));
}
screen_.parent().addComponent(*h);
screen_.parent().focus(*h);
h->notifyEvent(DrawAllEvent());
}
virtual ScreenEndUserInputEventHandler* clone() const
{
return new ScreenEndUserInputEventHandler(*this);
}
};
}
#endif //FRONTEND_SCREENENDUSERINPUTEVENTHANDLER_H