Jump to content

TUnipanel konum hatırlama


yakup

Recommended Posts

Merhabalar,

Uygulamada minik widgetler kullanıyorum, rapor gibi. bu widgetler panel içerisinde,  Panel ise draggable modunda. Kullanıcı istediği yere sürükleyip bırakabiliyor hizalayabiliyor.

Hizalama sonrası pozisyonları coockie kaydediyorum.

Aynı kullanıcı yeniden oturum açınca ilgili panellerin, Kullanıcın daha önce ayarladığı önceki konumlarını coockie den okuyup atamasını yapıyorum (Main.Onshow'da) Ancak Panel o konuma gelmiyor.

Sanırım biraz gecikmeli yapsam olur deyip Timer koydum Runonce modunda, MainForm onshow olayında timer çalıştırıp konumları setleyince bu resimdeki hata dönüyor.

Ama ekrana bir buton koyup, Timeri o buton içinde start edersem paneller olması gereken konumlara geçiyor. Veya Timer aradan çıkarıp bir butonla atama yaparsam yine paneller istediğim pozisyona geliyor.

Kısaca panelin yeniden konumlanmaları için illaki bir butonla tetiklemek gerekiyor. Burada nasıl bir mantık kurabilirim panellerin pozisyonlarını oturum açıldığında nasıl değiştirebilirim.

 

image.thumb.png.1a61534b1bf65a72293cce65a71bdf07.png

 

Konumlanma procedure içi,

  DragPanel1.Left := StrToIntDef(UniApplication.Cookies.GetCookie
    ('DragPanel1_L'), 5);
  DragPanel1.Top := StrToIntDef(UniApplication.Cookies.GetCookie
    ('DragPanel1_T'), 15);

  DragPanel2.Left := StrToIntDef(UniApplication.Cookies.GetCookie
    ('DragPanel2_L'), 25);
  DragPanel2.Top := StrToIntDef(UniApplication.Cookies.GetCookie
    ('DragPanel2_T'), 200);

  DragPanel3.Left := StrToIntDef(UniApplication.Cookies.GetCookie
    ('DragPanel3_L'), 25);
  DragPanel3.Top := StrToIntDef(UniApplication.Cookies.GetCookie
    ('DragPanel3_T'), 200);

 

Link to comment
Share on other sites

One of the possible solutions:

1. 

function beforeInit(sender, config)
{
    Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));
    config.stateId = 'uniqueNamePanel'; //Must assign a unique stateId
    config.stateful = true; //Optional
}

2. 

function move(sender, x, y, eOpts) 
{
    Ext.defer(function() {
        var props = {
            x: sender.x,
            y: sender.y
        };
        Ext.state.Manager.set(sender.stateId + "Props", props);
    }, 1000)
}

3. 

function boxready(sender, width, height, eOpts) 
{
    var props = Ext.state.Manager.get(sender.stateId + "Props");
    if (props) {
        sender.setPosition([props.x, props.y])
    }
}

 

Link to comment
Share on other sites

On 3/10/2023 at 9:10 PM, Sherzod said:

One of the possible solutions:

1. 

function beforeInit(sender, config)
{
    Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));
    config.stateId = 'uniqueNamePanel'; //Must assign a unique stateId
    config.stateful = true; //Optional
}

2. 

function move(sender, x, y, eOpts) 
{
    Ext.defer(function() {
        var props = {
            x: sender.x,
            y: sender.y
        };
        Ext.state.Manager.set(sender.stateId + "Props", props);
    }, 1000)
}

3. 

function boxready(sender, width, height, eOpts) 
{
    var props = Ext.state.Manager.get(sender.stateId + "Props");
    if (props) {
        sender.setPosition([props.x, props.y])
    }
}

 

 

 

it work, thank you

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...