Author Topic: applyLayout etc commands missing from key bindings dialog  (Read 322 times)

Graeme

  • Senior Community Member
  • Posts: 2702
  • Hero Points: 336
applyLayout etc commands missing from key bindings dialog
« on: August 07, 2021, 10:30:54 am »
In layouts.e there are some layout commands applyLayout etc.
They don't show up in the keybindings dialog or in the help.
This is the same as 25.0.2.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6209
  • Hero Points: 482
Re: applyLayout etc commands missing from key bindings dialog
« Reply #1 on: August 07, 2021, 02:27:51 pm »
It looks like these commands are not supported as key bindings. They all have the VSARG2_EXECUTE_FROM_MENU_ONLY attribute. Can't say I know why though.

Graeme

  • Senior Community Member
  • Posts: 2702
  • Hero Points: 336
Re: applyLayout etc commands missing from key bindings dialog
« Reply #2 on: August 07, 2021, 11:28:27 pm »
ah, thankyou.  I don't pay enough attention to name attributes.  I should remember that functions called from menus need to be commands.  The source code says this
Code: [Select]
   /**
    * This command can only be executed from a menu.                 
    * This flag is in a way redundant since you can get the same     
    * effect with more control by writing an _OnUpdate.  However, it 
    * takes much less time to just add this attribute to a command.   
    */
   VSARG2_EXECUTE_FROM_MENU_ONLY = 0x80000000,
I don't understand the comment in the source.

I have  a macro that floats a window and tries to set a layout by calling applyLayout but it hasn't been working due to _MDICurrent() (in setCurrentLayout()) not returning the mdi of the new window.  I've got it to work by calling tw_clear(mdi)  - luckily it's global.  It's not nice but I couldn't find any other way.  It seems that _on_create_floating_mdi() must be getting called before float_window() returns to my code.  xfloat1 is normally called from a menu but it seems to work if I call it from the command line.

Code: [Select]
_command void xfloat1() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_MDI_EDITORCTL)
{
   if (_no_child_windows()) {
      return;
   }
   int wid = p_window_id; // The name_info() args above guarantee p_window_id is an editor control

   float_window();
   if ( xfloat_data._length() < 1 ) {
      _message_box('Call xset_float1 to set window pos and layout.');
      return;
   }
   int mdi = _MDIFromChild(wid); 
   //if ( mdi > 0 ) {
      mdi.p_x =           xfloat_data[0].px;
      mdi.p_y =           xfloat_data[0].py;
      mdi.p_width =       xfloat_data[0].pw;
      mdi.p_height =      xfloat_data[0].ph;

      tw_clear(mdi);        // <<<<<<<<<<<<<<<<<<<<<<<

      if ( _MDICurrent() == mdi ) {
         applyLayout(xfloat_data[0].layout_name);
      }
      xxdebug("px py pw ph", xfloat_data[0].px, mdi.p_x, mdi.p_y, mdi.p_width, mdi.p_height, xfloat_data[0].layout_name);
   //}
}


Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6209
  • Hero Points: 482
Re: applyLayout etc commands missing from key bindings dialog
« Reply #3 on: August 08, 2021, 11:06:39 pm »
If I add an optional mdiWid argument to applyLayout, would that help?

Graeme

  • Senior Community Member
  • Posts: 2702
  • Hero Points: 336
Re: applyLayout etc commands missing from key bindings dialog
« Reply #4 on: August 09, 2021, 08:31:08 am »
Thanks, it would help but I think I'd rather not take up your time.  I found another way - by calling mdisetfocus instead of tw_clear.  It works in slick V20 / 2015 as well - so I think that will do.

I am curious as to why calling float-window() doesn't leave _MDICurrent() returning the ID of the new mdi  - just mentioning in case it's a bug.
Thanks.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6209
  • Hero Points: 482
Re: applyLayout etc commands missing from key bindings dialog
« Reply #5 on: August 09, 2021, 01:13:37 pm »
Not a bug. Many GUI operations are supposed to let the window manager dictate which window is active or has focus.

Graeme

  • Senior Community Member
  • Posts: 2702
  • Hero Points: 336
Re: applyLayout etc commands missing from key bindings dialog
« Reply #6 on: August 11, 2021, 11:49:17 am »
It turns out that mdisetfocus isn't always working - but that's ok, tw_clear works so that will do.