mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
add 200ms delay before starting drag'n'drop
This commit is contained in:
@@ -58,7 +58,7 @@ CardListBase* CardSelectEvent::getTheCardList() const {
|
||||
// ----------------------------------------------------------------------------- : CardListBase
|
||||
|
||||
CardListBase::CardListBase(Window* parent, int id, long additional_style)
|
||||
: ItemList(parent, id, additional_style, true)
|
||||
: ItemList(parent, id, additional_style, true) , drop_timer(this, ID_DROP_TIMER)
|
||||
{
|
||||
drop_target = new CardListDropTarget(this);
|
||||
}
|
||||
@@ -626,17 +626,23 @@ void CardListBase::onChar(wxKeyEvent& ev) {
|
||||
}
|
||||
}
|
||||
|
||||
void CardListBase::onBeginDrag(wxListEvent&) {
|
||||
vector<CardP> cards;
|
||||
getSelection(cards);
|
||||
String transaction_id = generate_uid();
|
||||
CardsOnClipboard* card_data = new CardsOnClipboard(set, transaction_id, cards);
|
||||
drop_target->ignored_id = transaction_id;
|
||||
wxDropSource drag_source(this);
|
||||
drag_source.SetData(*card_data);
|
||||
drag_source.DoDragDrop(wxDrag_CopyOnly);
|
||||
void CardListBase::onBeginDrag(wxListEvent&) {
|
||||
drop_timer.Start(200, wxTIMER_ONE_SHOT);
|
||||
}
|
||||
|
||||
void CardListBase::OnDragTimer(wxTimerEvent& ev) {
|
||||
if (ev.GetId() == ID_DROP_TIMER && wxGetMouseState().LeftIsDown()) {
|
||||
vector<CardP> cards;
|
||||
getSelection(cards);
|
||||
String transaction_id = generate_uid();
|
||||
CardsOnClipboard* card_data = new CardsOnClipboard(set, transaction_id, cards);
|
||||
drop_target->ignored_id = transaction_id;
|
||||
wxDropSource drag_source(this);
|
||||
drag_source.SetData(*card_data);
|
||||
drag_source.DoDragDrop(wxDrag_CopyOnly);
|
||||
}
|
||||
}
|
||||
|
||||
void CardListBase::onDrag(wxMouseEvent& ev) {
|
||||
ev.Skip();
|
||||
if (!allowModify()) return;
|
||||
@@ -704,7 +710,8 @@ BEGIN_EVENT_TABLE(CardListBase, ItemList)
|
||||
EVT_LIST_COL_RIGHT_CLICK (wxID_ANY, CardListBase::onColumnRightClick)
|
||||
EVT_LIST_COL_END_DRAG (wxID_ANY, CardListBase::onColumnResize)
|
||||
EVT_LIST_ITEM_ACTIVATED (wxID_ANY, CardListBase::onItemActivate)
|
||||
EVT_LIST_BEGIN_DRAG (wxID_ANY, CardListBase::onBeginDrag)
|
||||
EVT_LIST_BEGIN_DRAG (wxID_ANY, CardListBase::onBeginDrag)
|
||||
EVT_TIMER (ID_DROP_TIMER, CardListBase::OnDragTimer)
|
||||
EVT_CHAR ( CardListBase::onChar)
|
||||
EVT_MOTION ( CardListBase::onDrag)
|
||||
EVT_MENU (ID_SELECT_COLUMNS, CardListBase::onSelectColumns)
|
||||
|
||||
@@ -70,8 +70,9 @@ public:
|
||||
inline void setCard(const CardP& card, bool event = false) { selectItem(card, true, event); }
|
||||
|
||||
// --------------------------------------------------- : Clipboard and Drag'n'Drop
|
||||
|
||||
|
||||
CardListDropTarget* drop_target;
|
||||
wxTimer drop_timer;
|
||||
|
||||
bool canCut() const override;
|
||||
bool canCopy() const override;
|
||||
@@ -167,7 +168,8 @@ private:
|
||||
void onItemActivate (wxListEvent&);
|
||||
void onSelectColumns (wxCommandEvent&);
|
||||
void onChar (wxKeyEvent&);
|
||||
void onBeginDrag (wxListEvent&);
|
||||
void onBeginDrag (wxListEvent&);
|
||||
void OnDragTimer (wxTimerEvent&);
|
||||
void onDrag (wxMouseEvent&);
|
||||
void onContextMenu (wxContextMenuEvent&);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user