Jump to content

andyhill

uniGUI Subscriber
  • Posts

    955
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by andyhill

  1. Yes, all good Sherzod. I did ask a while ago to please add to the TUniCanvas/TunimCanvas object an "updated" event. We already have a Ready event that fires once only after initialisation. In other words, every time we execute a canvas drawing instruction:- ... UniSession.AddJS('var ctx = fMain.MyCanvas._cc_; '+ '{ '+ stroke/fill etc. '}; ' ); ... procedure TfMain.MyCanvasAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = 'updated' then begin ... end; end; At present we have to allow sufficient time before next action, it would be good to not rely on time but instead an event.
  2. My memory came back to me 🤐 I have to wait till Canvas is ready, different updates have different timings so what worked before now takes more time.
  3. Am I having a bad hair day ? (7.4.0, 1.90.1556) What used to work from my memory is now failing me ??? Please advise what I have forgotten - Thanks. Minimum Shell Project attached. Project1.zip
  4. This helped me a long time ago:- ServerModule procedure UniGUIServerModuleException(Sender: TUniGUIMainModule; AException: Exception; var Handled: Boolean); ... procedure TUniServerModule.UniGUIServerModuleException(Sender: TUniGUIMainModule; AException: Exception; var Handled: Boolean); var s, Msg: String; p1, p2, p3: Integer; begin DateTimeToString(formattedDateTime, 'dd/mm/yyyy hh:nn:ss.z', Now()); try if Assigned(Sender) then begin try (sender as TUniMainModule).LogException(AException); except s:= 'debug'; end; Handled:= True; end else begin if AException <> nil then begin Msg:= AException.Message; p1:= Pos('Invalid URI:', Msg); p2:= Pos('EIdOSSLAcceptError :', Msg); p3:= Pos('Session not found:', Msg); if (p1+p2+p3) > 0 then begin Handled:= True; end else begin Logger.AddLog('ANDY-S', formattedDateTime+', UnAssigned MainModule "'+Msg+'"'); Handled:= True; end; end else begin if IgnoreAccessViolation = True then begin Handled:= True; end; end; end; except end; end; MainModule public // procedure LogException(E: Exception); end; ... // Called By ServerModule procedure TUniMainModule.LogException(E: Exception); var Cmp: TComponent; s, s0, s1, s2, Msg, formattedDateTime: String; begin s:= 'http'; if SecureFlag = True then begin s:= 'HTTPS'; end; DateTimeToString(formattedDateTime, 'dd/mm/yyyy hh:nn:ss.z', Now()); s0:= ''; //formattedDateTime; if UserName <> '' then begin s0:= UserName + ' ' + formattedDateTime; end; try if E <> nil then begin Msg:= E.Message; Cmp:= TUniGUIApplication(UniApplication).UniSession.CurrentComponent; if Assigned(Cmp) then begin s1:= Cmp.Name + ' (' + Cmp.ClassName + ')'; // Owner ? uniGUIBaseClasses, uniGUIClasses, uniGUIRegClasses if Cmp is TUniControl then s2:= TUniControl(Cmp).OwnerForm.Name else if Cmp is TUniComponent then s2:= TUniComponent(Cmp).OwnerForm.Name else s2:= ''; uniServerModule.Logger.AddLog('ANDY-M', 'EXCEPTION - ' + s + ', IP: ' + UniSession.RemoteIP + ', SessionID: ' + UniSession.SessionID + ', UserName: ' + UserName + ', Component: ' + s1 + ', Msg: "' + Msg + '"'); end else begin if uniServerModule.IgnoreAccessViolation = True then begin uniServerModule.Logger.AddLog('ANDY-M', 'EXCEPTION - ' + s + ', IP: ' + UniSession.RemoteIP + ', SessionID: ' + UniSession.SessionID + ', UserName: ' + UserName + ', Msg: "' + Msg + '"'); end; end; // Assigned end else begin // nil if uniServerModule.IgnoreAccessViolation = True then begin uniServerModule.Logger.AddLog('ANDY-M', 'EXCEPTION - ' + s + ', IP: ' + UniSession.RemoteIP + ', SessionID: ' + UniSession.SessionID + ', UserName: ' + UserName + ', Msg: "UnKnown Error"'); end; end; // nil except end; end;
  5. Thank you, would you be so kind as to use my sample project above and show me in code how to accomplish said task
  6. Thanks for the tip, I have used requestAnimationFrame on a TUniCanvas before - all good. This is a THTMLFrame that requires scrolling from code. UniHTMLFrame1.JSInterface.JSCall('body.setScrollTop', [0]); $('+UniHTMLFrame1.JSName+').scrollTop(currentScroll+1);'+ Top Bottom CurrentPos etc.
  7. Thanks Sherzod, still curious why JavaScript failed.
  8. This code does not work, please advise - Thanks in advance. ////////////////////////////////////////////////////////////////////////////// HtmlMemo.BeginUpdate; HtmlMemo.Lines.Clear; s:= '<!DOCTYPE html><html>'+ ' <head>'+ ' <style>'+ ' @media print'+ ' {'+ ' html, body'+ ' {'+ ' height: auto;'+ ' font-size: 12pt;'+ ' }'+ ' }'+ ' </style>'+ ' </head>'+ ' <body>'; HtmlMemo.Lines.Add(s); ////////////////////////////////////////////////////////////////////////////// // Needed For UnDo/ReDo HtmlMemo.Lines.Add('<div id="content"> '); ... html content ////////////////////////////////////////////////////////////////////////////// // Content Div s:= ' </div>'; HtmlMemo.Lines.Add(s); s:= '<div id="buttons"> '+ ' <button type="button" id="undo_btn">Undo</button> '+ ' <button type="button" id="redo_btn">Redo</button> '+ '</div> '+ '<script type="text/javascript"> '+ ' var StateUndoRedo = function() '+ ' { '+ ' var init = function(opts) '+ ' { '+ ' var self = this; '+ ' self.opts = opts; '+ ' if(typeof(self.opts[''undo_disabled'']) == ''undefined'') '+ ' { '+ ' self.opts[''undo_disabled''] = function() {}; '+ ' } '+ ' if(typeof(self.opts[''undo_enabled'']) == ''undefined'') '+ ' { '+ ' self.opts[''undo_enabled''] = function() {}; '+ ' } '+ ' if(typeof(self.opts[''redo_disabled'']) == ''undefined'') '+ ' { '+ ' self.opts[''redo_disabled''] = function() {}; '+ ' } '+ ' if(typeof(self.opts[''redo_enabled'']) == ''undefined'') '+ ' { '+ ' self.opts[''redo_enabled''] = function() {}; '+ ' } '+ ' if(typeof(self.opts[''restore'']) == ''undefined'') '+ ' { '+ ' self.opts[''restore''] = function() {}; '+ ' } '+ ' self.opts[''undo_disabled''](); '+ ' self.opts[''redo_disabled''](); '+ ' } // init '+ ' var add = function(state) '+ ' { '+ ' var self = this; '+ ' if(typeof(self.states) == ''undefined'') '+ ' { '+ ' self.states = []; '+ ' } '+ ' if(typeof(self.state_index) == ''undefined'') '+ ' { '+ ' self.state_index = -1; '+ ' } '+ ' self.state_index++; '+ ' self.states[self.state_index] = state; '+ ' self.states.length = self.state_index + 1; '+ ' if(self.state_index > 0) '+ ' { '+ ' self.opts[''undo_enabled''](); '+ ' } '+ ' self.opts[''redo_disabled''](); '+ ' } // add '+ ' var undo = function() '+ ' { '+ ' var self = this; '+ ' if(self.state_index > 0) '+ ' { '+ ' self.state_index--; '+ ' if(self.state_index == 0) '+ ' { '+ ' self.opts[''undo_disabled''](); '+ ' } else { '+ ' self.opts[''undo_enabled''](); '+ ' } '+ ' self.opts[''redo_enabled''](); '+ ' self.opts[''restore''](self.states[self.state_index]); '+ ' } '+ ' } // undo '+ ' var redo = function() '+ ' { '+ ' var self = this; '+ ' if(self.state_index < self.states.length) '+ ' { '+ ' self.state_index++; '+ ' if(self.state_index == self.states.length - 1) '+ ' { '+ ' self.opts[''redo_disabled''](); '+ ' } else { '+ ' self.opts[''redo_enabled''](); '+ ' } '+ ' self.opts[''undo_enabled''](); '+ ' self.opts[''restore''](self.states[self.state_index]); '+ ' } '+ ' } // redo '+ ' var restore = function() '+ ' { '+ ' var self = this; '+ ' self.opts[''restore''](self.states[self.state_index]); '+ ' } // restore '+ ' var clear = function() '+ ' { '+ ' var self = this; '+ ' self.state_index = 0; '+ ' //self.states = []; '+ ' } // clear '+ ' return '+ ' { '+ ' init: init, '+ ' add: add, '+ ' undo: undo, '+ ' redo: redo, '+ ' restore: restore, '+ ' clear: clear '+ ' }; // StateUndoRedo '+ ' }; // StateUndoRedo '+ ' //initialize object '+ ' var o = new StateUndoRedo(); '+ ' o.init( '+ ' { '+ ' ''undo_disabled'': function() '+ ' { '+ ' //make the undo button hidden '+ ' document.getElementById("undo_btn").disabled = true; '+ ' }, '+ ' ''undo_enabled'': function() '+ ' { '+ ' //make the undo button visible '+ ' document.getElementById("undo_btn").disabled = false; '+ ' }, '+ ' ''redo_disabled'': function() '+ ' { '+ ' //make the redo button hidden '+ ' document.getElementById("redo_btn").disabled = true; '+ ' }, '+ ' ''redo_enabled'': function() '+ ' { '+ ' //make the redo button visible '+ ' document.getElementById("redo_btn").disabled = false; '+ ' }, '+ ' ''restore'': function(state) '+ ' { '+ ' //replace the current content with the restored state content '+ ' document.getElementById("content").innerHTML = state; '+ ' } '+ ' }); '+ ' //initialize first state '+ ' o.add(document.getElementById("content").innerHTML); '+ ' o.restore(); '+ ' o.clear(); '+ ' //bind click events for undo/redo buttons '+ ' document.getElementById("undo_btn").addEventListener("click", function() '+ ' { '+ ' o.undo(); '+ ' }); '+ ' document.getElementById("redo_btn").addEventListener("click", function() '+ ' { '+ ' o.redo(); '+ ' }); '+ ' //bind change events for content element '+ ' document.getElementById(''content'').addEventListener("change", function(event) '+ ' { '+ ' // the following is required since vanilla JS innerHTML '+ ' // does not capture user-changed values of inputs '+ ' // so we set the attributes explicitly (use jQuery to avoid this) '+ ' var elems = document.querySelectorAll("#content input"); '+ ' for(var i = 0; i < elems.length; i++) '+ ' { '+ ' elems[i].setAttribute("value", elems[i].value); '+ ' } '+ ' //take a snapshot of the current state of the content element '+ ' o.add(document.getElementById("content").innerHTML); '+ ' }); '+ '</script> '; HtmlMemo.Lines.Add(s); ////////////////////////////////////////////////////////////////////////////// // Finalise s:= ' </body>'+ '</html>'; HtmlMemo.Lines.Add(s); HtmlMemo.EndUpdate;
  9. Noted Sherzod, that's why I asked for help and included the website URL (where one can see the tele-prompter at work) in my code. I look forward to your advice on how to do this in UniGUI - thanks again.
  10. NO, I want code to scroll the contents at a pace set by my code. Please see:- https://codepen.io/startupsandcode/pen/MmXWaO Already commented in my code.
  11. 1) Load HtmlFrame with display text / images 2) PLAY: Slowly Scroll HtmlFrame contents 3) PAUSE: Stop Scrolling 4) UNPAUSE(PLAY): Slowly Scroll HtmlFrame contents from current position 5) STOP WHEN REACHING THE END (1) and (5) are coded (2), (3) and (4) are the results of user interaction processed via JavaScript
  12. All my attempts to read / write / update current scroll position fail. The current code should fail as did the original. Please advise Thanks Sherzod
  13. Attached is a shell project that I am having problems with Auto-Scroll, I would be happy for any help to solve - Thanks in advance. Project1.zip
  14. Within my Secondary Form Create Event I re-populate a RadioGroupBox at runtime based on entry parameters as follows:- grOptions.BeginUpdate; grOptions.Items.Clear; if fMain.BuildProtocolFlag = True then begin grOptions.Items.Add('ADD To Custom Protocol'); grOptions.Height:= 50; grOptions.ItemIndex:= 0; grOptions.EndUpdate; end else begin grOptions.Items.Add('ReName Custom Protocol'); grOptions.Items.Add('ReEdit Custom Protocol'); grOptions.Items.Add('DELETE Custom Protocol'); grOptions.Height:= 90; grOptions.ItemIndex:= -1; grOptions.EndUpdate; end; // btnProcess.Top:= grOptions.Top + grOptions.Height + 10; btnCancel.Top:= grOptions.Top + grOptions.Height + 10; // Height:= btnProcess.Top + btnProcess.Height + 45; All works exactly as intended. QUESTION: As my development PC is a Microsoft Surface Notebook which runs at a super high screen dpi, I am questioning my padding values in red for non server low resolution renditions, is there a universal way to do this effectively - that is, cater for all sorts of dpi rendered browsers (without flex) ?
  15. I guess a shell project reproducing this problem would help.
  16. Not sure if this will help but this is how I get my desired results:- MainForm.Create ... InfoHTMLFrame.ClientEvents.UniEvents.Clear; s:= 'beforeInit=function beforeInit(sender, config)'#13#10+ '{ '#13#10+ ' config.minHeight = 1850;'#13#10+ // a requirement for me ' config.minWidth = 800;'#13#10+ // a requirement for me ' config.overflowX = true;'#13#10+ //' config.overflowY = true;'#13#10+ '} '; InfoHTMLFrame.ClientEvents.UniEvents.Add(s); ... Elsewhere in code:- After updating html script at runtime I call InfoHTMLFrame.ReCalculateAligns;
  17. Thank You. Well finally got it compiled Do you have an example of "in servermodule just create module, create ws , destroy ws , free module" where one can test the working functionality of the ws ?
×
×
  • Create New...