Jump to content

Recommended Posts

Posted

Hello, I'd like to have the ability to mouseover/mouseenter a unipanel and have the panel change color and/or display some other type of effect, such as a solid white border - something similar to clicking a tile in windows 8, then return to the original color/initial effect at mouseleave.

 

Would anyone know of a way to do this within unigui? Thank in advance.

Posted

Hello rsanford..

 

Change color and font of label:

 

procedure TUniMainModule.setze_label_schwarz(was:TUniLabel);
begin
      was.Cursor:=crHandPoint;
      was.Font.Color:=UniMainModule.schwarz;
      was.Font.Style:=was.Font.Style + [];
end;

 

 

 

change color of panel:

 

procedure TUniMainModule.setze_panel_dunkelgrau(was:TUniPanel);
begin
     was.Cursor:=crDefault;
     was.ClientEvents.ExtEvents.Add
      ('OnAfterrender=function OnAfterrender(sender)'+
      ' {  sender.setBodyStyle("background-color:'+ColorToHtml(dunkelgrau)+'");  }');
end;

 

 

change to round corners and color of panel:

 

procedure TUniMainModule.setze_panel_rund_dunkelgrau(was:TUniPanel);
begin
     was.Cursor:=crDefault;
     was.ClientEvents.ExtEvents.Add
         ('OnAfterrender=function OnAfterrender(sender)'+
       ' {  sender.setBodyStyle("background:'+ColorToHtml(dunkelgrau)+'; -webkit-border-radius: 5px; -khtml-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px");  }');
end;

 

 

change color on mouseover:

 

procedure TUniMainModule.funktion_panel_hoover_dunkelgrau_zu_grau(was:TUniPanel);
begin
   was.Cursor:=crHandPoint;
   was.ClientEvents.ExtEvents.Add
      ('OnAfterrender=function OnAfterrender(sender)'+
      ' {  sender.setBodyStyle("background-color:'+ColorToHtml(dunkelgrau)+'"); }');
   was.ClientEvents.ExtEvents.Add
      ('OnMouseout=function Onmouseout(sender)'+
      ' { sender.body.applyStyles("background-color:'+ColorToHtml(dunkelgrau)+'"); }');
   was.ClientEvents.ExtEvents.Add
      ('Onmouseover=function Onmouseover(sender)'+
      ' {sender.body.applyStyles("background-color:'+ColorToHtml(grau)+'"); }');
end;

 

 

change color on mouseover and round corners:

 

procedure TUniMainModule.funktion_panel_rund_hoover_dunkelgrau_zu_grau(was:TUniPanel);
begin
   was.Cursor:=crHandPoint;
   was.ClientEvents.ExtEvents.Add
      ('OnAfterrender=function OnAfterrender(sender)'+
      ' {  sender.setBodyStyle("background-color:'+ColorToHtml(dunkelgrau)+'; -webkit-border-radius: 5px; -khtml-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px");  }');
   was.ClientEvents.ExtEvents.Add
      ('OnMouseout=function Onmouseout(sender)'+
      ' { sender.body.applyStyles("background-color:'+ColorToHtml(dunkelgrau)+'"); }');
   was.ClientEvents.ExtEvents.Add
      ('Onmouseover=function Onmouseover(sender)'+
      ' {sender.body.applyStyles("background-color:'+ColorToHtml(grau)+'"); }');
end;

 

 

and the colorToHtml thing:

 

function TUniMainModule.ColorToHtml(DColor:TColor):string;
  var
    tmpRGB : TColorRef;
  begin
    tmpRGB := ColorToRGB(DColor) ;
    Result:=Format('#%.2x%.2x%.2x',
                   [GetRValue(tmpRGB),
                    GetGValue(tmpRGB),
                    GetBValue(tmpRGB)]) ;
  end; {function ColorToHtml}

 

 

 

hth

 

erich

  • Upvote 1
Posted

Simple version:

-> in "TUniPanel / ClientEvents / ExtEvents -> OnAfterrender":
 

function OnAfterrender(sender)
{
document.getElementById(sender.body.id).className += " hoverpanel";
}

 

-> in "UniServerModule / CustomCSS": 
 

.hoverpanel:hover {
background-color: #0077FF;
}
  • Upvote 2
Posted

Hi,

 

Very easy, 

 

Client Side

 

ClientEvents->ExtEvents

 

function Onmouseover(sender)
{
   sender.addCls('effectPanel'); // Method extjs http://docs.extjs.com/extjs/4.2.1/#!/api/Ext.panel.Panel-method-addCls
}

 

 

function Onmouseout(sender)
{
   sender.removeCls('effectPanel'); // Method extjs http://docs.extjs.com/extjs/4.2.1/#!/api/Ext.panel.Panel-method-removeCls
}

 

ServerModule.pas -> CustomCSS

 

.effectPanel {

 your effects

}

 

OR

 

create file css and declare into ServerModule.pas -> CustomFiles

 

PerJanBR

  • Like 1
  • Upvote 3
  • 1 month later...
Posted

Hi

What's the syntax for adding this functionality in a dynamically created panel for example ?

 

 

Simple version:

-> in "TUniPanel / ClientEvents / ExtEvents -> OnAfterrender":
 

function OnAfterrender(sender)
{
document.getElementById(sender.body.id).className += " hoverpanel";
}

 

 

I've tried various things like this below but no joy yet .......

 

// add a panel to the display form

Apanel.create(frmDisp);

Apanel. parent := .....

etc

etc

//add some event handlers

//serverside

Apanel.OnClick := clicked;

//Clientside     THIS IS NOT HOW TO DO IT !!!

Apanel.ClientEvents.ExtEvents.Add('function onAfterrender(sender) {  document.getElementById(sender.body.id).className += " hoverpanel";  }');  

Many thanks

Posted
//Clientside     THIS IS NOT HOW TO DO IT !!!

Apanel.ClientEvents.ExtEvents.Add('function onAfterrender(sender) {  document.getElementById(sender.body.id).className += " hoverpanel";  }');  

 

Try this:

Apanel.ClientEvents.ExtEvents.Add('onAfterrender=function onAfterrender(sender) { ...
Posted

Hi Oliver

 

Many thanks for the reply.

Unfortunately I'm not getting anything with this :

Apanel.ClientEvents.ExtEvents.Add('OnAfterrender=function OnAfterrender(sender){document.getElementById(sender.body.id).className += " hoverpanel";}');

 

This works fine in the same app using the in-place editor to add an event handler for the onAfterrender event of a design time created panel.

OnAfterrender(sender){document.getElementById(sender.body.id).className += " hoverpanel";}');

 

Any ideas ?

 

Cheers

Posted

Hi Oliver

 

Many thanks for the reply.

Unfortunately I'm not getting anything with this :

Apanel.ClientEvents.ExtEvents.Add('OnAfterrender=function OnAfterrender(sender){document.getElementById(sender.body.id).className += " hoverpanel";}');

 

This works fine in the same app using the in-place editor to add an event handler for the onAfterrender event of a design time created panel.

OnAfterrender(sender){document.getElementById(sender.body.id).className += " hoverpanel";}');

 

Any ideas ?

 

Cheers

 

This works for me (you must give the component a unique name):

procedure TMainForm.UniButton4Click(Sender: TObject);
var
  aPnl: TUniPanel;
begin
  aPnl := TUniPanel.Create(self);
  aPnl.Left:= 30;
  aPnl.Top := 400;
  aPnl.Caption := 'Test';
  aPnl.Name := 'MyTestPanel';
  aPnl.ClientEvents.ExtEvents.Add('OnAfterrender=function OnAfterrender(sender){document.getElementById(sender.body.id).className += " hoverpanel";}');
  aPnl.Parent := self;
end;

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...