Skip to content

Commit

Permalink
Stop using dynamic_cast when performing text drag (Mac OS only).
Browse files Browse the repository at this point in the history
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10536 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Jan 28, 2015
1 parent b8b8917 commit 64ffd41
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions FL/mac.H
Expand Up @@ -186,6 +186,7 @@ public:
static int insertion_point_location(int *px, int *py, int *pheight); // computes window coordinates & height of insertion point
static const int CoreText_threshold; // Mac OS version from which the Core Text API is used to display text
static Fl_Fontdesc* calc_fl_fonts(void); // computes the fl_fonts global variable
static int dnd(int use_selection); // call Fl_X::dnd(1) to support text dragging
private:
#if FLTK_ABI_VERSION >= 10304
CGRect* subRect_; // makes sure subwindow remains inside its parent window
Expand Down
7 changes: 6 additions & 1 deletion src/Fl_Input.cxx
Expand Up @@ -678,7 +678,12 @@ int Fl_Input::handle(int event) {
dnd_save_mark = mark();
dnd_save_focus = this;
// drag the data:
copy(0); Fl::dnd();
copy(0);
#ifdef __APPLE__
Fl_X::dnd(1);
#else
Fl::dnd();
#endif
return 1;
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/Fl_Text_Display.cxx
Expand Up @@ -3863,7 +3863,11 @@ int Fl_Text_Display::handle(int event) {
if (dragType==DRAG_START_DND) {
if (!Fl::event_is_click() && Fl::dnd_text_ops()) {
const char* copy = buffer()->selection_text();
#ifdef __APPLE__
Fl_X::dnd(1);
#else
Fl::dnd();
#endif
free((void*)copy);
}
return 1;
Expand Down
9 changes: 7 additions & 2 deletions src/Fl_cocoa.mm
Expand Up @@ -4001,7 +4001,12 @@ static void createAppleMenu(void)
return image;
}

int Fl::dnd(void)
int Fl::dnd()
{
return Fl_X::dnd(0);
}

int Fl_X::dnd(int use_selection)
{
CFDataRef text = CFDataCreate(kCFAllocatorDefault, (UInt8*)fl_selection_buffer[0], fl_selection_length[0]);
if (text==NULL) return false;
Expand All @@ -4018,7 +4023,7 @@ static void createAppleMenu(void)

int width, height;
NSImage *image;
if ( dynamic_cast<Fl_Input_*>(w) != NULL || dynamic_cast<Fl_Text_Display*>(w) != NULL) {
if (use_selection) {
fl_selection_buffer[0][ fl_selection_length[0] ] = 0;
image = imageFromText(fl_selection_buffer[0], &width, &height);
} else {
Expand Down

0 comments on commit 64ffd41

Please sign in to comment.