DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2842
Version: 1.3-feature


When user clicked right mouse button somewhere in Fluid app (and invoked
New menu) it would be quite reasonable to put new widget right there,
wouldn't?
My followed patch gives such possibility. Perhaps my implementation is not
very elegant, but it works.


Link: http://www.fltk.org/str.php?L2842
Version: 1.3-feature
--- fltk/fluid/Fl_Type.h
+++ fltk/fluid/Fl_Type.h
@@ -589,6 +589,7 @@
   void copy_properties();
 
   int sr_min_w, sr_min_h, sr_max_w, sr_max_h;
+  static int popupx,popupy;
 };
 
 class Fl_Widget_Class_Type : private Fl_Window_Type {

--- fltk/fluid/Fl_Window_Type.cxx
+++ fltk/fluid/Fl_Window_Type.cxx
@@ -1172,6 +1172,9 @@
   update_xywh();
 }
 
+int Fl_Window_Type::popupx = -1;
+int Fl_Window_Type::popupy = -1;
+
 int Fl_Window_Type::handle(int event) {
   static Fl_Type* selection;
   switch (event) {
@@ -1183,9 +1186,11 @@
     if (Fl::event_button() >= 3) {
       in_this_only = this; // modifies how some menu items work.
       static const Fl_Menu_Item* myprev;
+      popupx = mx; popupy = my;
       const Fl_Menu_Item* m = New_Menu->popup(mx,my,"New",myprev);
       if (m && m->callback()) {myprev = m; m->do_callback(this->o);}
       in_this_only = 0;
+      popupx = popupy = -1;
       return 1;
     }
     // find the innermost item clicked on:

--- fltk/fluid/factory.cxx
+++ fltk/fluid/factory.cxx
@@ -985,8 +985,12 @@
         // Move and resize the menubar across the top of the window...
         wt->o->resize(0, 0, w, h);
       } else {
-        // Just resize to the ideal size...
-        wt->o->size(w, h);
+        if (Fl_Window_Type::popupx < 0 || Fl_Window_Type::popupy < 0) {
+            // Just resize to the ideal size...
+            wt->o->size(w, h);
+        } else {
+            wt->o->resize(Fl_Window_Type::popupx, Fl_Window_Type::popupy, w, 
h);
+        }
       }
     }
     select_only(t);

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to